Update:Remove playback sessions that are 3s or less on startup

This commit is contained in:
advplyr 2023-12-21 14:29:36 -06:00
parent 76119445a3
commit 24a587b944

View File

@ -1,5 +1,5 @@
const Path = require('path') const Path = require('path')
const { Sequelize } = require('sequelize') const { Sequelize, Op } = require('sequelize')
const packageJson = require('../package.json') const packageJson = require('../package.json')
const fs = require('./libs/fsExtra') const fs = require('./libs/fsExtra')
@ -698,6 +698,7 @@ class Database {
* Clean invalid records in database * Clean invalid records in database
* Series should have atleast one Book * Series should have atleast one Book
* Book and Podcast must have an associated LibraryItem * Book and Podcast must have an associated LibraryItem
* Remove playback sessions that are 3 seconds or less
*/ */
async cleanDatabase() { async cleanDatabase() {
// Remove invalid Podcast records // Remove invalid Podcast records
@ -738,6 +739,18 @@ class Database {
Logger.warn(`Found series "${series.name}" with no books - removing it`) Logger.warn(`Found series "${series.name}" with no books - removing it`)
await series.destroy() await series.destroy()
} }
// Remove playback sessions that were 3 seconds or less
const badSessionsRemoved = await this.playbackSessionModel.destroy({
where: {
timeListening: {
[Op.lte]: 3
}
}
})
if (badSessionsRemoved > 0) {
Logger.warn(`Removed ${badSessionsRemoved} sessions that were 3 seconds or less`)
}
} }
} }