ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

remove-old-views-scheduler.ts 961 B

12345678910111213141516171819202122232425262728293031
  1. import { VideoViewModel } from '@server/models/view/video-view.js'
  2. import { logger } from '../../helpers/logger.js'
  3. import { CONFIG } from '../../initializers/config.js'
  4. import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants.js'
  5. import { AbstractScheduler } from './abstract-scheduler.js'
  6. export class RemoveOldViewsScheduler extends AbstractScheduler {
  7. private static instance: AbstractScheduler
  8. protected schedulerIntervalMs = SCHEDULER_INTERVALS_MS.REMOVE_OLD_VIEWS
  9. private constructor () {
  10. super()
  11. }
  12. protected internalExecute () {
  13. if (CONFIG.VIEWS.VIDEOS.REMOTE.MAX_AGE === -1) return
  14. logger.info('Removing old videos views.')
  15. const now = new Date()
  16. const beforeDate = new Date(now.getTime() - CONFIG.VIEWS.VIDEOS.REMOTE.MAX_AGE).toISOString()
  17. return VideoViewModel.removeOldRemoteViewsHistory(beforeDate)
  18. }
  19. static get Instance () {
  20. return this.instance || (this.instance = new this())
  21. }
  22. }