1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-06 03:50:26 +02:00

Improve viewer counter

More precise, avoid weird decrease, reuse an id to federate viewers
This commit is contained in:
Chocobozzz 2022-04-06 08:50:43 +02:00 committed by Chocobozzz
parent dfbcefc20d
commit ac907dc7c1
17 changed files with 235 additions and 156 deletions

View file

@ -145,18 +145,10 @@ class Redis {
return this.setValue(this.generateIPViewKey(ip, videoUUID), '1', VIEW_LIFETIME.VIEW)
}
setIPVideoViewer (ip: string, videoUUID: string) {
return this.setValue(this.generateIPViewerKey(ip, videoUUID), '1', VIEW_LIFETIME.VIEWER_COUNTER)
}
async doesVideoIPViewExist (ip: string, videoUUID: string) {
return this.exists(this.generateIPViewKey(ip, videoUUID))
}
async doesVideoIPViewerExist (ip: string, videoUUID: string) {
return this.exists(this.generateIPViewerKey(ip, videoUUID))
}
/* ************ Tracker IP block ************ */
setTrackerBlockIP (ip: string) {
@ -361,10 +353,6 @@ class Redis {
return `views-${videoUUID}-${ip}`
}
private generateIPViewerKey (ip: string, videoUUID: string) {
return `viewer-${videoUUID}-${ip}`
}
private generateTrackerBlockIPKey (ip: string) {
return `tracker-block-ip-${ip}`
}