2022-04-07 10:53:35 +02:00
|
|
|
import { pick } from '@shared/core-utils'
|
2022-03-24 13:36:47 +01:00
|
|
|
import { HttpStatusCode, VideoStatsOverall, VideoStatsRetention, VideoStatsTimeserie, VideoStatsTimeserieMetric } from '@shared/models'
|
|
|
|
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
|
|
|
|
|
|
|
export class VideoStatsCommand extends AbstractCommand {
|
|
|
|
|
|
|
|
getOverallStats (options: OverrideCommandOptions & {
|
|
|
|
videoId: number | string
|
2022-05-05 14:12:57 +02:00
|
|
|
startDate?: string
|
|
|
|
endDate?: string
|
2022-03-24 13:36:47 +01:00
|
|
|
}) {
|
|
|
|
const path = '/api/v1/videos/' + options.videoId + '/stats/overall'
|
|
|
|
|
|
|
|
return this.getRequestBody<VideoStatsOverall>({
|
|
|
|
...options,
|
|
|
|
path,
|
|
|
|
|
2022-05-05 14:12:57 +02:00
|
|
|
query: pick(options, [ 'startDate', 'endDate' ]),
|
|
|
|
|
2022-03-24 13:36:47 +01:00
|
|
|
implicitToken: true,
|
|
|
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
getTimeserieStats (options: OverrideCommandOptions & {
|
|
|
|
videoId: number | string
|
|
|
|
metric: VideoStatsTimeserieMetric
|
2022-04-07 10:53:35 +02:00
|
|
|
startDate?: Date
|
|
|
|
endDate?: Date
|
2022-03-24 13:36:47 +01:00
|
|
|
}) {
|
|
|
|
const path = '/api/v1/videos/' + options.videoId + '/stats/timeseries/' + options.metric
|
|
|
|
|
|
|
|
return this.getRequestBody<VideoStatsTimeserie>({
|
|
|
|
...options,
|
|
|
|
path,
|
|
|
|
|
2022-04-07 10:53:35 +02:00
|
|
|
query: pick(options, [ 'startDate', 'endDate' ]),
|
2022-03-24 13:36:47 +01:00
|
|
|
implicitToken: true,
|
|
|
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
getRetentionStats (options: OverrideCommandOptions & {
|
|
|
|
videoId: number | string
|
|
|
|
}) {
|
|
|
|
const path = '/api/v1/videos/' + options.videoId + '/stats/retention'
|
|
|
|
|
|
|
|
return this.getRequestBody<VideoStatsRetention>({
|
|
|
|
...options,
|
|
|
|
path,
|
|
|
|
|
|
|
|
implicitToken: true,
|
|
|
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|