From 49f0468d44468528c2fb2c8b0efd19cdaeeec43d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 5 May 2022 14:12:57 +0200 Subject: Add filter by start/end date overall stats in api --- server/tests/api/views/video-views-overall-stats.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'server/tests/api/views') diff --git a/server/tests/api/views/video-views-overall-stats.ts b/server/tests/api/views/video-views-overall-stats.ts index 72b072c96..53b8f0d4b 100644 --- a/server/tests/api/views/video-views-overall-stats.ts +++ b/server/tests/api/views/video-views-overall-stats.ts @@ -141,6 +141,27 @@ describe('Test views overall stats', function () { } }) + it('Should filter overall stats by date', async function () { + this.timeout(60000) + + const beforeView = new Date() + + await servers[0].views.simulateViewer({ id: vodVideoId, currentTimes: [ 0, 3 ] }) + await processViewersStats(servers) + + { + const stats = await servers[0].videoStats.getOverallStats({ videoId: vodVideoId, startDate: beforeView.toISOString() }) + expect(stats.averageWatchTime).to.equal(3) + expect(stats.totalWatchTime).to.equal(3) + } + + { + const stats = await servers[0].videoStats.getOverallStats({ videoId: liveVideoId, endDate: beforeView.toISOString() }) + expect(stats.averageWatchTime).to.equal(22) + expect(stats.totalWatchTime).to.equal(88) + } + }) + after(async function () { await stopFfmpeg(command) }) -- cgit v1.2.3