mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Add filter by start/end date overall stats in api
This commit is contained in:
@@ -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()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user