1 import { pick } from '@shared/core-utils'
2 import { HttpStatusCode, VideoStatsOverall, VideoStatsRetention, VideoStatsTimeserie, VideoStatsTimeserieMetric } from '@shared/models'
3 import { AbstractCommand, OverrideCommandOptions } from '../shared'
5 export class VideoStatsCommand extends AbstractCommand {
7 getOverallStats (options: OverrideCommandOptions & {
8 videoId: number | string
12 const path = '/api/v1/videos/' + options.videoId + '/stats/overall'
14 return this.getRequestBody<VideoStatsOverall>({
18 query: pick(options, [ 'startDate', 'endDate' ]),
21 defaultExpectedStatus: HttpStatusCode.OK_200
25 getTimeserieStats (options: OverrideCommandOptions & {
26 videoId: number | string
27 metric: VideoStatsTimeserieMetric
31 const path = '/api/v1/videos/' + options.videoId + '/stats/timeseries/' + options.metric
33 return this.getRequestBody<VideoStatsTimeserie>({
37 query: pick(options, [ 'startDate', 'endDate' ]),
39 defaultExpectedStatus: HttpStatusCode.OK_200
43 getRetentionStats (options: OverrideCommandOptions & {
44 videoId: number | string
46 const path = '/api/v1/videos/' + options.videoId + '/stats/retention'
48 return this.getRequestBody<VideoStatsRetention>({
53 defaultExpectedStatus: HttpStatusCode.OK_200