Update controllers to use toOldJSON functions

This commit is contained in:
advplyr 2025-01-04 15:20:41 -06:00
parent 7fae25a726
commit 6d52f88a96
20 changed files with 277 additions and 202 deletions

View file

@ -665,7 +665,7 @@ class Database {
/**
* Clean invalid records in database
* Series should have atleast one Book
* Book and Podcast must have an associated LibraryItem
* Book and Podcast must have an associated LibraryItem (and vice versa)
* Remove playback sessions that are 3 seconds or less
*/
async cleanDatabase() {
@ -695,6 +695,28 @@ class Database {
await book.destroy()
}
// Remove invalid LibraryItem records
const libraryItemsWithNoMedia = await this.libraryItemModel.findAll({
include: [
{
model: this.bookModel,
attributes: ['id']
},
{
model: this.podcastModel,
attributes: ['id']
}
],
where: {
'$book.id$': null,
'$podcast.id$': null
}
})
for (const libraryItem of libraryItemsWithNoMedia) {
Logger.warn(`Found libraryItem "${libraryItem.id}" with no media - removing it`)
await libraryItem.destroy()
}
const playlistMediaItemsWithNoMediaItem = await this.playlistMediaItemModel.findAll({
include: [
{