mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-15 17:52:25 +02:00
Update controllers to use toOldJSON functions
This commit is contained in:
@ -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: [
|
||||
{
|
||||
|
Reference in New Issue
Block a user