mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-01 08:44:40 +02:00
Update controllers to use toOldJSON functions
This commit is contained in:
parent
7fae25a726
commit
6d52f88a96
20 changed files with 277 additions and 202 deletions
|
@ -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: [
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue