aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/views/shared/video-viewer-stats.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-07-12 09:51:21 +0200
committerChocobozzz <me@florianbigard.com>2022-07-12 09:51:21 +0200
commita49407524fc1212299a41d7c5330f27b36112167 (patch)
treea66b85ec224b169fdceaba4b6f2fd487a394a2f8 /server/lib/views/shared/video-viewer-stats.ts
parent0f7195fa401a0b647961cf1fcc57412445d80acd (diff)
downloadPeerTube-a49407524fc1212299a41d7c5330f27b36112167.tar.gz
PeerTube-a49407524fc1212299a41d7c5330f27b36112167.tar.zst
PeerTube-a49407524fc1212299a41d7c5330f27b36112167.zip
Prevent invalid watch sections
Diffstat (limited to 'server/lib/views/shared/video-viewer-stats.ts')
-rw-r--r--server/lib/views/shared/video-viewer-stats.ts7
1 files changed, 6 insertions, 1 deletions
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 {
104 }) 104 })
105 } else { 105 } else {
106 const lastSection = stats.watchSections[stats.watchSections.length - 1] 106 const lastSection = stats.watchSections[stats.watchSections.length - 1]
107 lastSection.end = currentTime 107
108 if (lastSection.start > currentTime) {
109 logger.warn('Invalid end watch section %d. Last start record was at %d.', currentTime, lastSection.start)
110 } else {
111 lastSection.end = currentTime
112 }
108 } 113 }
109 114
110 stats.watchTime = this.buildWatchTimeFromSections(stats.watchSections) 115 stats.watchTime = this.buildWatchTimeFromSections(stats.watchSections)