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:
parent
49f0468d44
commit
f40712abbb
15 changed files with 383 additions and 107 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue