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
10 const path = '/api/v1/videos/' + options.videoId + '/stats/overall'
12 return this.getRequestBody<VideoStatsOverall>({
17 defaultExpectedStatus: HttpStatusCode.OK_200
21 getTimeserieStats (options: OverrideCommandOptions & {
22 videoId: number | string
23 metric: VideoStatsTimeserieMetric
27 const path = '/api/v1/videos/' + options.videoId + '/stats/timeseries/' + options.metric
29 return this.getRequestBody<VideoStatsTimeserie>({
33 query: pick(options, [ 'startDate', 'endDate' ]),
35 defaultExpectedStatus: HttpStatusCode.OK_200
39 getRetentionStats (options: OverrideCommandOptions & {
40 videoId: number | string
42 const path = '/api/v1/videos/' + options.videoId + '/stats/retention'
44 return this.getRequestBody<VideoStatsRetention>({
49 defaultExpectedStatus: HttpStatusCode.OK_200