From 160c83df4a0206f54cfa501c781032e5c8745cc6 Mon Sep 17 00:00:00 2001 From: advplyr Date: Sat, 30 Dec 2023 16:14:14 -0600 Subject: [PATCH] Update:podcastEpisodes table index added for createdAt column #2073 #2075 --- server/controllers/LibraryItemController.js | 1 - server/models/LibraryItem.js | 6 +++++- server/models/PodcastEpisode.js | 7 ++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/server/controllers/LibraryItemController.js b/server/controllers/LibraryItemController.js index b0ecf446..f462c081 100644 --- a/server/controllers/LibraryItemController.js +++ b/server/controllers/LibraryItemController.js @@ -49,7 +49,6 @@ class LibraryItemController { item.episodesDownloading = [this.podcastManager.currentDownload.toJSONForClient()] } } - return res.json(item) } res.json(req.libraryItem) diff --git a/server/models/LibraryItem.js b/server/models/LibraryItem.js index ffd2f9c0..67e9abfb 100644 --- a/server/models/LibraryItem.js +++ b/server/models/LibraryItem.js @@ -421,6 +421,10 @@ class LibraryItem extends Model { if (!libraryItemId) return null const libraryItem = await this.findByPk(libraryItemId) + if (!libraryItem) { + Logger.error(`[LibraryItem] Library item not found with id "${libraryItemId}"`) + return null + } if (libraryItem.mediaType === 'podcast') { libraryItem.media = await libraryItem.getMedia({ @@ -453,7 +457,7 @@ class LibraryItem extends Model { }) } - if (!libraryItem) return null + if (!libraryItem.media) return null return this.getOldLibraryItem(libraryItem) } diff --git a/server/models/PodcastEpisode.js b/server/models/PodcastEpisode.js index 55b2f9d4..2fdefb86 100644 --- a/server/models/PodcastEpisode.js +++ b/server/models/PodcastEpisode.js @@ -152,7 +152,12 @@ class PodcastEpisode extends Model { extraData: DataTypes.JSON }, { sequelize, - modelName: 'podcastEpisode' + modelName: 'podcastEpisode', + indexes: [ + { + fields: ['createdAt'] + } + ] }) const { podcast } = sequelize.models