diff options
author | Chocobozzz <me@florianbigard.com> | 2018-12-03 09:14:56 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-12-03 09:14:56 +0100 |
commit | dbe6aa698eaacf9125d2c4232dee6e3e1f0d7ba1 (patch) | |
tree | b844e12a501fa14b4806a222bf162e7dc0f086f0 /server/lib/job-queue/handlers | |
parent | 1a8dd4da77468068d1ff7f7bd67f76399ae04e04 (diff) | |
download | PeerTube-dbe6aa698eaacf9125d2c4232dee6e3e1f0d7ba1.tar.gz PeerTube-dbe6aa698eaacf9125d2c4232dee6e3e1f0d7ba1.tar.zst PeerTube-dbe6aa698eaacf9125d2c4232dee6e3e1f0d7ba1.zip |
Fix trending page
Diffstat (limited to 'server/lib/job-queue/handlers')
-rw-r--r-- | server/lib/job-queue/handlers/video-views.ts | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/server/lib/job-queue/handlers/video-views.ts b/server/lib/job-queue/handlers/video-views.ts index f44c3c727..038ef43e2 100644 --- a/server/lib/job-queue/handlers/video-views.ts +++ b/server/lib/job-queue/handlers/video-views.ts | |||
@@ -24,12 +24,10 @@ async function processVideosViews () { | |||
24 | try { | 24 | try { |
25 | const views = await Redis.Instance.getVideoViews(videoId, hour) | 25 | const views = await Redis.Instance.getVideoViews(videoId, hour) |
26 | if (isNaN(views)) { | 26 | if (isNaN(views)) { |
27 | logger.error('Cannot process videos views of video %d in hour %d: views number is NaN.', videoId, hour) | 27 | logger.error('Cannot process videos views of video %d in hour %d: views number is NaN (%s).', videoId, hour, views) |
28 | } else { | 28 | } else { |
29 | logger.debug('Adding %d views to video %d in hour %d.', views, videoId, hour) | 29 | logger.debug('Adding %d views to video %d in hour %d.', views, videoId, hour) |
30 | 30 | ||
31 | await VideoModel.incrementViews(videoId, views) | ||
32 | |||
33 | try { | 31 | try { |
34 | await VideoViewModel.create({ | 32 | await VideoViewModel.create({ |
35 | startDate, | 33 | startDate, |
@@ -39,7 +37,14 @@ async function processVideosViews () { | |||
39 | }) | 37 | }) |
40 | 38 | ||
41 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId) | 39 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId) |
42 | if (video.isOwned()) await federateVideoIfNeeded(video, false) | 40 | if (video.isOwned()) { |
41 | // If this is a remote video, the origin instance will send us an update | ||
42 | await VideoModel.incrementViews(videoId, views) | ||
43 | |||
44 | // Send video update | ||
45 | video.views += views | ||
46 | await federateVideoIfNeeded(video, false) | ||
47 | } | ||
43 | } catch (err) { | 48 | } catch (err) { |
44 | logger.debug('Cannot create video views for video %d in hour %d. Maybe the video does not exist anymore?', videoId, hour) | 49 | logger.debug('Cannot create video views for video %d in hour %d. Maybe the video does not exist anymore?', videoId, hour) |
45 | } | 50 | } |