]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/server-commands/videos/video-stats-command.ts
Add filter by start/end date overall stats in api
[github/Chocobozzz/PeerTube.git] / shared / server-commands / videos / video-stats-command.ts
index 90f7ffeaf3e1a086e6cd32a93dce59b2d55d1593..b9b99bfb57ec0f9e2a9f140439e71e1ff5e8f081 100644 (file)
@@ -1,3 +1,4 @@
+import { pick } from '@shared/core-utils'
 import { HttpStatusCode, VideoStatsOverall, VideoStatsRetention, VideoStatsTimeserie, VideoStatsTimeserieMetric } from '@shared/models'
 import { AbstractCommand, OverrideCommandOptions } from '../shared'
 
@@ -5,6 +6,8 @@ export class VideoStatsCommand extends AbstractCommand {
 
   getOverallStats (options: OverrideCommandOptions & {
     videoId: number | string
+    startDate?: string
+    endDate?: string
   }) {
     const path = '/api/v1/videos/' + options.videoId + '/stats/overall'
 
@@ -12,6 +15,8 @@ export class VideoStatsCommand extends AbstractCommand {
       ...options,
       path,
 
+      query: pick(options, [ 'startDate', 'endDate' ]),
+
       implicitToken: true,
       defaultExpectedStatus: HttpStatusCode.OK_200
     })
@@ -20,6 +25,8 @@ export class VideoStatsCommand extends AbstractCommand {
   getTimeserieStats (options: OverrideCommandOptions & {
     videoId: number | string
     metric: VideoStatsTimeserieMetric
+    startDate?: Date
+    endDate?: Date
   }) {
     const path = '/api/v1/videos/' + options.videoId + '/stats/timeseries/' + options.metric
 
@@ -27,6 +34,7 @@ export class VideoStatsCommand extends AbstractCommand {
       ...options,
       path,
 
+      query: pick(options, [ 'startDate', 'endDate' ]),
       implicitToken: true,
       defaultExpectedStatus: HttpStatusCode.OK_200
     })