From b211106695bb82f6c32e53306081b5262c3d109d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 24 Mar 2022 13:36:47 +0100 Subject: Support video views/viewers stats in server * Add "currentTime" and "event" body params to view endpoint * Merge watching and view endpoints * Introduce WatchAction AP activity * Add tables to store viewer information of local videos * Add endpoints to fetch video views/viewers stats of local videos * Refactor views/viewers handlers * Support "views" and "viewers" counters for both VOD and live videos --- scripts/benchmark.ts | 8 +++++--- scripts/ci.sh | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/benchmark.ts b/scripts/benchmark.ts index 623c11e27..4a414a2fa 100644 --- a/scripts/benchmark.ts +++ b/scripts/benchmark.ts @@ -153,21 +153,23 @@ async function run () { } }, { - title: 'API - watching', + title: 'API - views with token', method: 'PUT', headers: { ...buildAuthorizationHeader(), ...buildJSONHeader() }, body: JSON.stringify({ currentTime: 2 }), - path: '/api/v1/videos/' + video.uuid + '/watching', + path: '/api/v1/videos/' + video.uuid + '/views', expecter: (body, status) => { return status === 204 } }, { - title: 'API - views', + title: 'API - views without token', method: 'POST', + headers: buildJSONHeader(), + body: JSON.stringify({ currentTime: 2 }), path: '/api/v1/videos/' + video.uuid + '/views', expecter: (body, status) => { return status === 204 diff --git a/scripts/ci.sh b/scripts/ci.sh index a45f91a6b..2dd5e25ce 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -84,8 +84,9 @@ elif [ "$1" = "api-3" ]; then npm run build:server videosFiles=$(findTestFiles ./dist/server/tests/api/videos) + viewsFiles=$(findTestFiles ./dist/server/tests/api/views) - MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $videosFiles + MOCHA_PARALLEL=true runTest "$1" $((3*$speedFactor)) $viewsFiles $videosFiles elif [ "$1" = "api-4" ]; then npm run build:server -- cgit v1.2.3