diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/lib/job-queue/handlers/video-views.ts | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/server/lib/job-queue/handlers/video-views.ts b/server/lib/job-queue/handlers/video-views.ts index 8a011d109..cf180a11a 100644 --- a/server/lib/job-queue/handlers/video-views.ts +++ b/server/lib/job-queue/handlers/video-views.ts | |||
@@ -2,11 +2,17 @@ import { Redis } from '../../redis' | |||
2 | import { logger } from '../../../helpers/logger' | 2 | import { logger } from '../../../helpers/logger' |
3 | import { VideoModel } from '../../../models/video/video' | 3 | import { VideoModel } from '../../../models/video/video' |
4 | import { VideoViewModel } from '../../../models/video/video-views' | 4 | import { VideoViewModel } from '../../../models/video/video-views' |
5 | import { isTestInstance } from '../../../helpers/core-utils' | ||
5 | 6 | ||
6 | async function processVideosViewsViews () { | 7 | async function processVideosViewsViews () { |
7 | const hour = new Date().getHours() | 8 | const lastHour = new Date() |
8 | const startDate = new Date().setMinutes(0, 0, 0) | 9 | |
9 | const endDate = new Date().setMinutes(59, 59, 999) | 10 | // In test mode, we run this function multiple times per hour, so we don't want the values of the previous hour |
11 | if (!isTestInstance()) lastHour.setHours(lastHour.getHours() - 1) | ||
12 | |||
13 | const hour = lastHour.getHours() | ||
14 | const startDate = lastHour.setMinutes(0, 0, 0) | ||
15 | const endDate = lastHour.setMinutes(59, 59, 999) | ||
10 | 16 | ||
11 | const videoIds = await Redis.Instance.getVideosIdViewed(hour) | 17 | const videoIds = await Redis.Instance.getVideosIdViewed(hour) |
12 | if (videoIds.length === 0) return | 18 | if (videoIds.length === 0) return |