From a49407524fc1212299a41d7c5330f27b36112167 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 12 Jul 2022 09:51:21 +0200 Subject: [PATCH] Prevent invalid watch sections --- server/lib/views/shared/video-viewer-stats.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/lib/views/shared/video-viewer-stats.ts b/server/lib/views/shared/video-viewer-stats.ts index 542bd51cf..39e34fb90 100644 --- a/server/lib/views/shared/video-viewer-stats.ts +++ b/server/lib/views/shared/video-viewer-stats.ts @@ -104,7 +104,12 @@ export class VideoViewerStats { }) } else { const lastSection = stats.watchSections[stats.watchSections.length - 1] - lastSection.end = currentTime + + if (lastSection.start > currentTime) { + logger.warn('Invalid end watch section %d. Last start record was at %d.', currentTime, lastSection.start) + } else { + lastSection.end = currentTime + } } stats.watchTime = this.buildWatchTimeFromSections(stats.watchSections)