You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
main
${ noResults }
32 lines
961 B
TypeScript
32 lines
961 B
TypeScript
import { VideoViewModel } from '@server/models/view/video-view.js'
|
|||
import { logger } from '../../helpers/logger.js'
|
|||
import { CONFIG } from '../../initializers/config.js'
|
|||
import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants.js'
|
|||
import { AbstractScheduler } from './abstract-scheduler.js'
|
|||
|
|||
export class RemoveOldViewsScheduler extends AbstractScheduler {
|
|||
|
|||
private static instance: AbstractScheduler
|
|||
|
|||
protected schedulerIntervalMs = SCHEDULER_INTERVALS_MS.REMOVE_OLD_VIEWS
|
|||
|
|||
private constructor () {
|
|||
super()
|
|||
}
|
|||
|
|||
protected internalExecute () {
|
|||
if (CONFIG.VIEWS.VIDEOS.REMOTE.MAX_AGE === -1) return
|
|||
|
|||
logger.info('Removing old videos views.')
|
|||
|
|||
const now = new Date()
|
|||
const beforeDate = new Date(now.getTime() - CONFIG.VIEWS.VIDEOS.REMOTE.MAX_AGE).toISOString()
|
|||
|
|||
return VideoViewModel.removeOldRemoteViewsHistory(beforeDate)
|
|||
}
|
|||
|
|||
static get Instance () {
|
|||
return this.instance || (this.instance = new this())
|
|||
}
|
|||
}
|