aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/core-utils/common/date.ts2
-rw-r--r--shared/models/videos/stats/index.ts4
-rw-r--r--shared/models/videos/stats/video-stats-timeserie-group-interval.type.ts1
-rw-r--r--shared/models/videos/stats/video-stats-timeserie-query.model.ts4
-rw-r--r--shared/models/videos/stats/video-stats-timeserie.model.ts4
-rw-r--r--shared/server-commands/videos/video-stats-command.ts4
6 files changed, 18 insertions, 1 deletions
diff --git a/shared/core-utils/common/date.ts b/shared/core-utils/common/date.ts
index 3e4a3c08c..f0684ff86 100644
--- a/shared/core-utils/common/date.ts
+++ b/shared/core-utils/common/date.ts
@@ -43,6 +43,8 @@ function isLastWeek (d: Date) {
43 return getDaysDifferences(now, d) <= 7 43 return getDaysDifferences(now, d) <= 7
44} 44}
45 45
46// ---------------------------------------------------------------------------
47
46function timeToInt (time: number | string) { 48function timeToInt (time: number | string) {
47 if (!time) return 0 49 if (!time) return 0
48 if (typeof time === 'number') return time 50 if (typeof time === 'number') return time
diff --git a/shared/models/videos/stats/index.ts b/shared/models/videos/stats/index.ts
index d1e9c167c..5c4c9df2a 100644
--- a/shared/models/videos/stats/index.ts
+++ b/shared/models/videos/stats/index.ts
@@ -1,4 +1,6 @@
1export * from './video-stats-overall.model' 1export * from './video-stats-overall.model'
2export * from './video-stats-retention.model' 2export * from './video-stats-retention.model'
3export * from './video-stats-timeserie.model' 3export * from './video-stats-timeserie-group-interval.type'
4export * from './video-stats-timeserie-query.model'
4export * from './video-stats-timeserie-metric.type' 5export * from './video-stats-timeserie-metric.type'
6export * from './video-stats-timeserie.model'
diff --git a/shared/models/videos/stats/video-stats-timeserie-group-interval.type.ts b/shared/models/videos/stats/video-stats-timeserie-group-interval.type.ts
new file mode 100644
index 000000000..9609ecb72
--- /dev/null
+++ b/shared/models/videos/stats/video-stats-timeserie-group-interval.type.ts
@@ -0,0 +1 @@
export type VideoStatsTimeserieGroupInterval = 'one_day' | 'one_hour' | 'ten_minutes' | 'one_minute'
diff --git a/shared/models/videos/stats/video-stats-timeserie-query.model.ts b/shared/models/videos/stats/video-stats-timeserie-query.model.ts
new file mode 100644
index 000000000..f3a8430e1
--- /dev/null
+++ b/shared/models/videos/stats/video-stats-timeserie-query.model.ts
@@ -0,0 +1,4 @@
1export interface VideoStatsTimeserieQuery {
2 startDate?: string
3 endDate?: string
4}
diff --git a/shared/models/videos/stats/video-stats-timeserie.model.ts b/shared/models/videos/stats/video-stats-timeserie.model.ts
index d95e34f1d..99bbbe2e3 100644
--- a/shared/models/videos/stats/video-stats-timeserie.model.ts
+++ b/shared/models/videos/stats/video-stats-timeserie.model.ts
@@ -1,4 +1,8 @@
1import { VideoStatsTimeserieGroupInterval } from './video-stats-timeserie-group-interval.type'
2
1export interface VideoStatsTimeserie { 3export interface VideoStatsTimeserie {
4 groupInterval: VideoStatsTimeserieGroupInterval
5
2 data: { 6 data: {
3 date: string 7 date: string
4 value: number 8 value: number
diff --git a/shared/server-commands/videos/video-stats-command.ts b/shared/server-commands/videos/video-stats-command.ts
index 90f7ffeaf..bd4808f63 100644
--- a/shared/server-commands/videos/video-stats-command.ts
+++ b/shared/server-commands/videos/video-stats-command.ts
@@ -1,3 +1,4 @@
1import { pick } from '@shared/core-utils'
1import { HttpStatusCode, VideoStatsOverall, VideoStatsRetention, VideoStatsTimeserie, VideoStatsTimeserieMetric } from '@shared/models' 2import { HttpStatusCode, VideoStatsOverall, VideoStatsRetention, VideoStatsTimeserie, VideoStatsTimeserieMetric } from '@shared/models'
2import { AbstractCommand, OverrideCommandOptions } from '../shared' 3import { AbstractCommand, OverrideCommandOptions } from '../shared'
3 4
@@ -20,6 +21,8 @@ export class VideoStatsCommand extends AbstractCommand {
20 getTimeserieStats (options: OverrideCommandOptions & { 21 getTimeserieStats (options: OverrideCommandOptions & {
21 videoId: number | string 22 videoId: number | string
22 metric: VideoStatsTimeserieMetric 23 metric: VideoStatsTimeserieMetric
24 startDate?: Date
25 endDate?: Date
23 }) { 26 }) {
24 const path = '/api/v1/videos/' + options.videoId + '/stats/timeseries/' + options.metric 27 const path = '/api/v1/videos/' + options.videoId + '/stats/timeseries/' + options.metric
25 28
@@ -27,6 +30,7 @@ export class VideoStatsCommand extends AbstractCommand {
27 ...options, 30 ...options,
28 path, 31 path,
29 32
33 query: pick(options, [ 'startDate', 'endDate' ]),
30 implicitToken: true, 34 implicitToken: true,
31 defaultExpectedStatus: HttpStatusCode.OK_200 35 defaultExpectedStatus: HttpStatusCode.OK_200
32 }) 36 })