diff options
Diffstat (limited to 'server/lib/views/shared/video-viewers.ts')
-rw-r--r-- | server/lib/views/shared/video-viewers.ts | 7 |
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 | } |