From 6b6168606bc86430f6b7821c9d5f1c80d0425ebf Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 29 Aug 2018 16:26:25 +0200 Subject: Bufferize videos views in redis --- server/controllers/api/videos/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'server/controllers/api') 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) { const videoInstance = res.locals.video const ip = req.ip - const exists = await Redis.Instance.isViewExists(ip, videoInstance.uuid) + const exists = await Redis.Instance.isVideoIPViewExists(ip, videoInstance.uuid) if (exists) { logger.debug('View for ip %s and video %s already exists.', ip, videoInstance.uuid) return res.status(204).end() } - await videoInstance.increment('views') - await Redis.Instance.setView(ip, videoInstance.uuid) + await Promise.all([ + Redis.Instance.addVideoView(videoInstance.id), + Redis.Instance.setIPVideoView(ip, videoInstance.uuid) + ]) const serverAccount = await getServerActor() -- cgit v1.2.3