updated getAllOldLibraryItems to grab subset of eps

updated getAllOldLibraryItems to grab only the episodes in the playlist not every podcast episode from the podcast
This commit is contained in:
drwggm 2024-11-15 14:09:42 -05:00 committed by GitHub
parent 45f8b06d56
commit 875e6cabe8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,6 +10,7 @@ const { filePathToPOSIX, getFileTimestampsWithIno } = require('../utils/fileUtil
const LibraryFile = require('../objects/files/LibraryFile') const LibraryFile = require('../objects/files/LibraryFile')
const Book = require('./Book') const Book = require('./Book')
const Podcast = require('./Podcast') const Podcast = require('./Podcast')
const { Op } = require('sequelize');
/** /**
* @typedef LibraryFileObject * @typedef LibraryFileObject
@ -124,9 +125,13 @@ class LibraryItem extends Model {
* @param {import('sequelize').WhereOptions} [where] * @param {import('sequelize').WhereOptions} [where]
* @returns {Array<objects.LibraryItem>} old library items * @returns {Array<objects.LibraryItem>} old library items
*/ */
static async getAllOldLibraryItems(where = null) { static async getAllOldLibraryItems({ id: libraryItemIds, episodeIds }) {
let libraryItems = await this.findAll({ let libraryItems = await this.findAll({
where, where: {
id: {
[Op.in]: libraryItemIds
}
},
include: [ include: [
{ {
model: this.sequelize.models.book, model: this.sequelize.models.book,
@ -147,11 +152,14 @@ class LibraryItem extends Model {
}, },
{ {
model: this.sequelize.models.podcast, model: this.sequelize.models.podcast,
include: [ include: {
{ model: this.sequelize.models.podcastEpisode,
model: this.sequelize.models.podcastEpisode where: {
id: {
[Op.in]: episodeIds
}
}
} }
]
} }
] ]
}) })