]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/server-commands/videos/video-stats-command.ts
Support video views/viewers stats in server
[github/Chocobozzz/PeerTube.git] / shared / server-commands / videos / video-stats-command.ts
CommitLineData
b2111066
C
1import { HttpStatusCode, VideoStatsOverall, VideoStatsRetention, VideoStatsTimeserie, VideoStatsTimeserieMetric } from '@shared/models'
2import { AbstractCommand, OverrideCommandOptions } from '../shared'
3
4export class VideoStatsCommand extends AbstractCommand {
5
6 getOverallStats (options: OverrideCommandOptions & {
7 videoId: number | string
8 }) {
9 const path = '/api/v1/videos/' + options.videoId + '/stats/overall'
10
11 return this.getRequestBody<VideoStatsOverall>({
12 ...options,
13 path,
14
15 implicitToken: true,
16 defaultExpectedStatus: HttpStatusCode.OK_200
17 })
18 }
19
20 getTimeserieStats (options: OverrideCommandOptions & {
21 videoId: number | string
22 metric: VideoStatsTimeserieMetric
23 }) {
24 const path = '/api/v1/videos/' + options.videoId + '/stats/timeseries/' + options.metric
25
26 return this.getRequestBody<VideoStatsTimeserie>({
27 ...options,
28 path,
29
30 implicitToken: true,
31 defaultExpectedStatus: HttpStatusCode.OK_200
32 })
33 }
34
35 getRetentionStats (options: OverrideCommandOptions & {
36 videoId: number | string
37 }) {
38 const path = '/api/v1/videos/' + options.videoId + '/stats/retention'
39
40 return this.getRequestBody<VideoStatsRetention>({
41 ...options,
42 path,
43
44 implicitToken: true,
45 defaultExpectedStatus: HttpStatusCode.OK_200
46 })
47 }
48}