aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-29 16:26:25 +0200
committerChocobozzz <me@florianbigard.com>2018-08-30 15:03:18 +0200
commit6b6168606bc86430f6b7821c9d5f1c80d0425ebf (patch)
tree9aea6cf0875c9fee30c373eb4924b12d47d1e23c /server/controllers
parent2d9fea161fd4fc73994fc77951bafdccdc2071fd (diff)
downloadPeerTube-6b6168606bc86430f6b7821c9d5f1c80d0425ebf.tar.gz
PeerTube-6b6168606bc86430f6b7821c9d5f1c80d0425ebf.tar.zst
PeerTube-6b6168606bc86430f6b7821c9d5f1c80d0425ebf.zip
Bufferize videos views in redis
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/videos/index.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index a86cf4f99..be803490b 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -380,14 +380,16 @@ async function viewVideo (req: express.Request, res: express.Response) {
380 const videoInstance = res.locals.video 380 const videoInstance = res.locals.video
381 381
382 const ip = req.ip 382 const ip = req.ip
383 const exists = await Redis.Instance.isViewExists(ip, videoInstance.uuid) 383 const exists = await Redis.Instance.isVideoIPViewExists(ip, videoInstance.uuid)
384 if (exists) { 384 if (exists) {
385 logger.debug('View for ip %s and video %s already exists.', ip, videoInstance.uuid) 385 logger.debug('View for ip %s and video %s already exists.', ip, videoInstance.uuid)
386 return res.status(204).end() 386 return res.status(204).end()
387 } 387 }
388 388
389 await videoInstance.increment('views') 389 await Promise.all([
390 await Redis.Instance.setView(ip, videoInstance.uuid) 390 Redis.Instance.addVideoView(videoInstance.id),
391 Redis.Instance.setIPVideoView(ip, videoInstance.uuid)
392 ])
391 393
392 const serverAccount = await getServerActor() 394 const serverAccount = await getServerActor()
393 395