aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/views/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-04-05 15:15:09 +0200
committerChocobozzz <chocobozzz@cpy.re>2022-04-15 09:49:35 +0200
commitdfbcefc20dc64f0814b1f2e8e782a4ea1bd24db2 (patch)
tree887521117856c06e6c814a0eb79d67f85ffe8eff /server/lib/views/shared
parentd74bb0647c79748860ad39c4b7b1be59504b47b7 (diff)
downloadPeerTube-dfbcefc20dc64f0814b1f2e8e782a4ea1bd24db2.tar.gz
PeerTube-dfbcefc20dc64f0814b1f2e8e782a4ea1bd24db2.tar.zst
PeerTube-dfbcefc20dc64f0814b1f2e8e782a4ea1bd24db2.zip
Improve views/viewers documentation
Diffstat (limited to 'server/lib/views/shared')
-rw-r--r--server/lib/views/shared/video-viewers.ts7
1 files changed, 4 insertions, 3 deletions
diff --git a/server/lib/views/shared/video-viewers.ts b/server/lib/views/shared/video-viewers.ts
index 5c26f8982..4dad1f0e8 100644
--- a/server/lib/views/shared/video-viewers.ts
+++ b/server/lib/views/shared/video-viewers.ts
@@ -41,7 +41,7 @@ export class VideoViewers {
41 private processingViewerStats = false 41 private processingViewerStats = false
42 42
43 constructor () { 43 constructor () {
44 setInterval(() => this.cleanViewerCounters(), VIEW_LIFETIME.VIEWER) 44 setInterval(() => this.cleanViewerCounters(), VIEW_LIFETIME.VIEWER_COUNTER)
45 45
46 setInterval(() => this.processViewerStats(), VIEW_LIFETIME.VIEWER_STATS) 46 setInterval(() => this.processViewerStats(), VIEW_LIFETIME.VIEWER_STATS)
47 } 47 }
@@ -56,7 +56,7 @@ export class VideoViewers {
56 } 56 }
57 57
58 buildViewerExpireTime () { 58 buildViewerExpireTime () {
59 return new Date().getTime() + VIEW_LIFETIME.VIEWER 59 return new Date().getTime() + VIEW_LIFETIME.VIEWER_COUNTER
60 } 60 }
61 61
62 async getWatchTime (videoId: number, ip: string) { 62 async getWatchTime (videoId: number, ip: string) {
@@ -210,7 +210,7 @@ export class VideoViewers {
210 if (this.processingViewerStats) return 210 if (this.processingViewerStats) return
211 this.processingViewerStats = true 211 this.processingViewerStats = true
212 212
213 if (!isTestInstance()) logger.info('Processing viewers.', lTags()) 213 if (!isTestInstance()) logger.info('Processing viewer statistics.', lTags())
214 214
215 const now = new Date().getTime() 215 const now = new Date().getTime()
216 216
@@ -220,6 +220,7 @@ export class VideoViewers {
220 for (const key of allKeys) { 220 for (const key of allKeys) {
221 const stats: LocalViewerStats = await Redis.Instance.getLocalVideoViewer({ key }) 221 const stats: LocalViewerStats = await Redis.Instance.getLocalVideoViewer({ key })
222 222
223 // Process expired stats
223 if (stats.lastUpdated > now - VIEW_LIFETIME.VIEWER_STATS) { 224 if (stats.lastUpdated > now - VIEW_LIFETIME.VIEWER_STATS) {
224 continue 225 continue
225 } 226 }