]>
Commit | Line | Data |
---|---|---|
cda03765 C |
1 | import { logger } from '../../helpers/logger' |
2 | import { AbstractScheduler } from './abstract-scheduler' | |
3 | import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' | |
cda03765 | 4 | import { CONFIG } from '../../initializers/config' |
fd261a8d | 5 | import { VideoViewModel } from '../../models/video/video-view' |
cda03765 C |
6 | |
7 | export class RemoveOldViewsScheduler extends AbstractScheduler { | |
8 | ||
9 | private static instance: AbstractScheduler | |
10 | ||
11 | protected schedulerIntervalMs = SCHEDULER_INTERVALS_MS.removeOldViews | |
12 | ||
13 | private constructor () { | |
14 | super() | |
15 | } | |
16 | ||
17 | protected internalExecute () { | |
18 | if (CONFIG.VIEWS.VIDEOS.REMOTE.MAX_AGE === -1) return | |
19 | ||
20 | logger.info('Removing old videos views.') | |
21 | ||
22 | const now = new Date() | |
23 | const beforeDate = new Date(now.getTime() - CONFIG.VIEWS.VIDEOS.REMOTE.MAX_AGE).toISOString() | |
24 | ||
25 | return VideoViewModel.removeOldRemoteViewsHistory(beforeDate) | |
26 | } | |
27 | ||
28 | static get Instance () { | |
29 | return this.instance || (this.instance = new this()) | |
30 | } | |
31 | } |