diff options
author | Chocobozzz <me@florianbigard.com> | 2019-05-21 13:32:00 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-05-21 13:32:00 +0200 |
commit | 21d141c296541f41e399ec68aa7fa85e53d0dcb8 (patch) | |
tree | 19989484a387f4d5efde1e803696dfec204b2840 /server/lib/job-queue/handlers | |
parent | 432ebe8bddb407bfbe503b782d59b1ee4c0d6842 (diff) | |
parent | 63dc589865fa1882d38f1d9e0050d2341869d487 (diff) | |
download | PeerTube-21d141c296541f41e399ec68aa7fa85e53d0dcb8.tar.gz PeerTube-21d141c296541f41e399ec68aa7fa85e53d0dcb8.tar.zst PeerTube-21d141c296541f41e399ec68aa7fa85e53d0dcb8.zip |
Merge branch 'release/v1.3.0' into develop
Diffstat (limited to 'server/lib/job-queue/handlers')
-rw-r--r-- | server/lib/job-queue/handlers/video-views.ts | 11 |
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 | } |