From 63dc589865fa1882d38f1d9e0050d2341869d487 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 21 May 2019 13:14:27 +0200 Subject: Fix video views --- server/lib/job-queue/handlers/video-views.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'server/lib') 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 () { logger.debug('Adding %d views to video %d in hour %d.', views, videoId, hour) try { + const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId) + if (!video) { + logger.debug('Video %d does not exist anymore, skipping videos view addition.', videoId) + continue + } + await VideoViewModel.create({ startDate, endDate, @@ -34,7 +40,6 @@ async function processVideosViews () { videoId }) - const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId) if (video.isOwned()) { // If this is a remote video, the origin instance will send us an update await VideoModel.incrementViews(videoId, views) @@ -44,13 +49,13 @@ async function processVideosViews () { await federateVideoIfNeeded(video, false) } } catch (err) { - logger.debug('Cannot create video views for video %d in hour %d. Maybe the video does not exist anymore?', videoId, hour) + logger.error('Cannot create video views for video %d in hour %d.', videoId, hour, { err }) } } await Redis.Instance.deleteVideoViews(videoId, hour) } catch (err) { - logger.error('Cannot update video views of video %d in hour %d.', videoId, hour) + logger.error('Cannot update video views of video %d in hour %d.', videoId, hour, { err }) } } } -- cgit v1.2.3