mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-08 00:08:14 +01:00
Update:Remove playback sessions that are 3s or less on startup
This commit is contained in:
parent
76119445a3
commit
24a587b944
@ -1,5 +1,5 @@
|
||||
const Path = require('path')
|
||||
const { Sequelize } = require('sequelize')
|
||||
const { Sequelize, Op } = require('sequelize')
|
||||
|
||||
const packageJson = require('../package.json')
|
||||
const fs = require('./libs/fsExtra')
|
||||
@ -698,6 +698,7 @@ class Database {
|
||||
* Clean invalid records in database
|
||||
* Series should have atleast one Book
|
||||
* Book and Podcast must have an associated LibraryItem
|
||||
* Remove playback sessions that are 3 seconds or less
|
||||
*/
|
||||
async cleanDatabase() {
|
||||
// Remove invalid Podcast records
|
||||
@ -738,6 +739,18 @@ class Database {
|
||||
Logger.warn(`Found series "${series.name}" with no books - removing it`)
|
||||
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`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user