diff options
-rw-r--r-- | client/src/app/core/hotkeys/index.ts | 2 | ||||
-rw-r--r-- | server/lib/job-queue/handlers/video-views.ts | 39 |
2 files changed, 25 insertions, 16 deletions
diff --git a/client/src/app/core/hotkeys/index.ts b/client/src/app/core/hotkeys/index.ts index bd2ab5b7a..a8d807c71 100644 --- a/client/src/app/core/hotkeys/index.ts +++ b/client/src/app/core/hotkeys/index.ts | |||
@@ -1 +1 @@ | |||
export * from './hotkeys.component' \ No newline at end of file | export * from './hotkeys.component' | ||
diff --git a/server/lib/job-queue/handlers/video-views.ts b/server/lib/job-queue/handlers/video-views.ts index 875d8ab88..8a011d109 100644 --- a/server/lib/job-queue/handlers/video-views.ts +++ b/server/lib/job-queue/handlers/video-views.ts | |||
@@ -14,22 +14,31 @@ async function processVideosViewsViews () { | |||
14 | logger.info('Processing videos views in job for hour %d.', hour) | 14 | logger.info('Processing videos views in job for hour %d.', hour) |
15 | 15 | ||
16 | for (const videoId of videoIds) { | 16 | for (const videoId of videoIds) { |
17 | const views = await Redis.Instance.getVideoViews(videoId, hour) | 17 | try { |
18 | if (isNaN(views)) { | 18 | const views = await Redis.Instance.getVideoViews(videoId, hour) |
19 | logger.error('Cannot process videos views of video %s in hour %d: views number is NaN.', videoId, hour) | 19 | if (isNaN(views)) { |
20 | } else { | 20 | logger.error('Cannot process videos views of video %d in hour %d: views number is NaN.', videoId, hour) |
21 | logger.debug('Adding %d views to video %d in hour %d.', views, videoId, hour) | 21 | } else { |
22 | 22 | logger.debug('Adding %d views to video %d in hour %d.', views, videoId, hour) | |
23 | await VideoModel.incrementViews(videoId, views) | 23 | |
24 | await VideoViewModel.create({ | 24 | await VideoModel.incrementViews(videoId, views) |
25 | startDate, | 25 | |
26 | endDate, | 26 | try { |
27 | views, | 27 | await VideoViewModel.create({ |
28 | videoId | 28 | startDate, |
29 | }) | 29 | endDate, |
30 | views, | ||
31 | videoId | ||
32 | }) | ||
33 | } catch (err) { | ||
34 | logger.debug('Cannot create video views for video %d in hour %d. Maybe the video does not exist anymore?', videoId, hour) | ||
35 | } | ||
36 | } | ||
37 | |||
38 | await Redis.Instance.deleteVideoViews(videoId, hour) | ||
39 | } catch (err) { | ||
40 | logger.error('Cannot update video views of video %d in hour %d.', videoId, hour) | ||
30 | } | 41 | } |
31 | |||
32 | await Redis.Instance.deleteVideoViews(videoId, hour) | ||
33 | } | 42 | } |
34 | } | 43 | } |
35 | 44 | ||