aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-13 13:59:41 +0200
committerChocobozzz <me@florianbigard.com>2018-09-13 14:14:15 +0200
commit6f0c46be8c9f4690d5e5cb758c4df6164b006f83 (patch)
tree8c8b56cc2415a6da42e2630b24a4f638b441bdc5 /server/lib
parentc48e82b5e0478434de30626d14594a97f2402e7c (diff)
downloadPeerTube-6f0c46be8c9f4690d5e5cb758c4df6164b006f83.tar.gz
PeerTube-6f0c46be8c9f4690d5e5cb758c4df6164b006f83.tar.zst
PeerTube-6f0c46be8c9f4690d5e5cb758c4df6164b006f83.zip
Process last hour views instead of current hour
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/job-queue/handlers/video-views.ts12
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'
2import { logger } from '../../../helpers/logger' 2import { logger } from '../../../helpers/logger'
3import { VideoModel } from '../../../models/video/video' 3import { VideoModel } from '../../../models/video/video'
4import { VideoViewModel } from '../../../models/video/video-views' 4import { VideoViewModel } from '../../../models/video/video-views'
5import { isTestInstance } from '../../../helpers/core-utils'
5 6
6async function processVideosViewsViews () { 7async 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