1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

Add ability to filter overall video stats by date

This commit is contained in:
Chocobozzz 2022-05-06 14:23:02 +02:00
parent 49f0468d44
commit f40712abbb
No known key found for this signature in database
GPG key ID: 583A612D890159BE
15 changed files with 383 additions and 107 deletions

View file

@ -67,18 +67,9 @@ async function getTimeserieStats (req: express.Request, res: express.Response) {
const stats = await LocalVideoViewerModel.getTimeserieStats({
video,
metric,
startDate: query.startDate ?? buildOneMonthAgo().toISOString(),
startDate: query.startDate ?? video.createdAt.toISOString(),
endDate: query.endDate ?? new Date().toISOString()
})
return res.json(stats)
}
function buildOneMonthAgo () {
const monthAgo = new Date()
monthAgo.setHours(0, 0, 0, 0)
monthAgo.setDate(monthAgo.getDate() - 29)
return monthAgo
}