Add filter by start/end date overall stats in api

This commit is contained in:
Chocobozzz
2022-05-05 14:12:57 +02:00
parent f18a060a83
commit 49f0468d44
9 changed files with 121 additions and 12 deletions

View File

@@ -75,8 +75,30 @@ describe('Test videos views', function () {
})
})
it('Should fail with an invalid start date', async function () {
await servers[0].videoStats.getOverallStats({
videoId,
startDate: 'fake' as any,
endDate: new Date().toISOString(),
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
it('Should fail with an invalid end date', async function () {
await servers[0].videoStats.getOverallStats({
videoId,
startDate: new Date().toISOString(),
endDate: 'fake' as any,
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
it('Should succeed with the correct parameters', async function () {
await servers[0].videoStats.getOverallStats({ videoId })
await servers[0].videoStats.getOverallStats({
videoId,
startDate: new Date().toISOString(),
endDate: new Date().toISOString()
})
})
})

View File

@@ -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)
})