aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-05-21 13:14:27 +0200
committerChocobozzz <me@florianbigard.com>2019-05-21 13:14:27 +0200
commit63dc589865fa1882d38f1d9e0050d2341869d487 (patch)
treec97359bbcc2ff6f104d5939ba891161cd03c9de0 /server/lib/job-queue
parentac3d2e05695883dabb435868272709b955dcb77a (diff)
downloadPeerTube-63dc589865fa1882d38f1d9e0050d2341869d487.tar.gz
PeerTube-63dc589865fa1882d38f1d9e0050d2341869d487.tar.zst
PeerTube-63dc589865fa1882d38f1d9e0050d2341869d487.zip
Fix video views
Diffstat (limited to 'server/lib/job-queue')
-rw-r--r--server/lib/job-queue/handlers/video-views.ts11
1 files changed, 8 insertions, 3 deletions
diff --git a/server/lib/job-queue/handlers/video-views.ts b/server/lib/job-queue/handlers/video-views.ts
index fa1fd13b3..73fa5ed04 100644
--- a/server/lib/job-queue/handlers/video-views.ts
+++ b/server/lib/job-queue/handlers/video-views.ts
@@ -27,6 +27,12 @@ async function processVideosViews () {
27 logger.debug('Adding %d views to video %d in hour %d.', views, videoId, hour) 27 logger.debug('Adding %d views to video %d in hour %d.', views, videoId, hour)
28 28
29 try { 29 try {
30 const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId)
31 if (!video) {
32 logger.debug('Video %d does not exist anymore, skipping videos view addition.', videoId)
33 continue
34 }
35
30 await VideoViewModel.create({ 36 await VideoViewModel.create({
31 startDate, 37 startDate,
32 endDate, 38 endDate,
@@ -34,7 +40,6 @@ async function processVideosViews () {
34 videoId 40 videoId
35 }) 41 })
36 42
37 const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId)
38 if (video.isOwned()) { 43 if (video.isOwned()) {
39 // If this is a remote video, the origin instance will send us an update 44 // If this is a remote video, the origin instance will send us an update
40 await VideoModel.incrementViews(videoId, views) 45 await VideoModel.incrementViews(videoId, views)
@@ -44,13 +49,13 @@ async function processVideosViews () {
44 await federateVideoIfNeeded(video, false) 49 await federateVideoIfNeeded(video, false)
45 } 50 }
46 } catch (err) { 51 } catch (err) {
47 logger.debug('Cannot create video views for video %d in hour %d. Maybe the video does not exist anymore?', videoId, hour) 52 logger.error('Cannot create video views for video %d in hour %d.', videoId, hour, { err })
48 } 53 }
49 } 54 }
50 55
51 await Redis.Instance.deleteVideoViews(videoId, hour) 56 await Redis.Instance.deleteVideoViews(videoId, hour)
52 } catch (err) { 57 } catch (err) {
53 logger.error('Cannot update video views of video %d in hour %d.', videoId, hour) 58 logger.error('Cannot update video views of video %d in hour %d.', videoId, hour, { err })
54 } 59 }
55 } 60 }
56} 61}