diff options
author | Chocobozzz <me@florianbigard.com> | 2022-05-06 14:23:02 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-05-06 14:23:02 +0200 |
commit | f40712abbbb74e51f06037ef02757c42736bccf8 (patch) | |
tree | 4b130c6387f9687d52d570907eb1bbac6bc04b61 /server/controllers/api/videos | |
parent | 49f0468d44468528c2fb2c8b0efd19cdaeeec43d (diff) | |
download | PeerTube-f40712abbbb74e51f06037ef02757c42736bccf8.tar.gz PeerTube-f40712abbbb74e51f06037ef02757c42736bccf8.tar.zst PeerTube-f40712abbbb74e51f06037ef02757c42736bccf8.zip |
Add ability to filter overall video stats by date
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r-- | server/controllers/api/videos/stats.ts | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/server/controllers/api/videos/stats.ts b/server/controllers/api/videos/stats.ts index 30e2bb06c..e79f01888 100644 --- a/server/controllers/api/videos/stats.ts +++ b/server/controllers/api/videos/stats.ts | |||
@@ -67,18 +67,9 @@ async function getTimeserieStats (req: express.Request, res: express.Response) { | |||
67 | const stats = await LocalVideoViewerModel.getTimeserieStats({ | 67 | const stats = await LocalVideoViewerModel.getTimeserieStats({ |
68 | video, | 68 | video, |
69 | metric, | 69 | metric, |
70 | startDate: query.startDate ?? buildOneMonthAgo().toISOString(), | 70 | startDate: query.startDate ?? video.createdAt.toISOString(), |
71 | endDate: query.endDate ?? new Date().toISOString() | 71 | endDate: query.endDate ?? new Date().toISOString() |
72 | }) | 72 | }) |
73 | 73 | ||
74 | return res.json(stats) | 74 | return res.json(stats) |
75 | } | 75 | } |
76 | |||
77 | function buildOneMonthAgo () { | ||
78 | const monthAgo = new Date() | ||
79 | monthAgo.setHours(0, 0, 0, 0) | ||
80 | |||
81 | monthAgo.setDate(monthAgo.getDate() - 29) | ||
82 | |||
83 | return monthAgo | ||
84 | } | ||