From b211106695bb82f6c32e53306081b5262c3d109d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 24 Mar 2022 13:36:47 +0100 Subject: Support video views/viewers stats in server * Add "currentTime" and "event" body params to view endpoint * Merge watching and view endpoints * Introduce WatchAction AP activity * Add tables to store viewer information of local videos * Add endpoints to fetch video views/viewers stats of local videos * Refactor views/viewers handlers * Support "views" and "viewers" counters for both VOD and live videos --- shared/models/videos/stats/index.ts | 4 ++++ shared/models/videos/stats/video-stats-overall.model.ts | 17 +++++++++++++++++ .../models/videos/stats/video-stats-retention.model.ts | 6 ++++++ .../videos/stats/video-stats-timeserie-metric.type.ts | 1 + .../models/videos/stats/video-stats-timeserie.model.ts | 6 ++++++ 5 files changed, 34 insertions(+) create mode 100644 shared/models/videos/stats/index.ts create mode 100644 shared/models/videos/stats/video-stats-overall.model.ts create mode 100644 shared/models/videos/stats/video-stats-retention.model.ts create mode 100644 shared/models/videos/stats/video-stats-timeserie-metric.type.ts create mode 100644 shared/models/videos/stats/video-stats-timeserie.model.ts (limited to 'shared/models/videos/stats') diff --git a/shared/models/videos/stats/index.ts b/shared/models/videos/stats/index.ts new file mode 100644 index 000000000..d1e9c167c --- /dev/null +++ b/shared/models/videos/stats/index.ts @@ -0,0 +1,4 @@ +export * from './video-stats-overall.model' +export * from './video-stats-retention.model' +export * from './video-stats-timeserie.model' +export * from './video-stats-timeserie-metric.type' diff --git a/shared/models/videos/stats/video-stats-overall.model.ts b/shared/models/videos/stats/video-stats-overall.model.ts new file mode 100644 index 000000000..f2a0470ef --- /dev/null +++ b/shared/models/videos/stats/video-stats-overall.model.ts @@ -0,0 +1,17 @@ +export interface VideoStatsOverall { + averageWatchTime: number + totalWatchTime: number + + viewersPeak: number + viewersPeakDate: string + + views: number + likes: number + dislikes: number + comments: number + + countries: { + isoCode: string + viewers: number + }[] +} diff --git a/shared/models/videos/stats/video-stats-retention.model.ts b/shared/models/videos/stats/video-stats-retention.model.ts new file mode 100644 index 000000000..e494888ed --- /dev/null +++ b/shared/models/videos/stats/video-stats-retention.model.ts @@ -0,0 +1,6 @@ +export interface VideoStatsRetention { + data: { + second: number + retentionPercent: number + }[] +} diff --git a/shared/models/videos/stats/video-stats-timeserie-metric.type.ts b/shared/models/videos/stats/video-stats-timeserie-metric.type.ts new file mode 100644 index 000000000..fc268d083 --- /dev/null +++ b/shared/models/videos/stats/video-stats-timeserie-metric.type.ts @@ -0,0 +1 @@ +export type VideoStatsTimeserieMetric = 'viewers' | 'aggregateWatchTime' diff --git a/shared/models/videos/stats/video-stats-timeserie.model.ts b/shared/models/videos/stats/video-stats-timeserie.model.ts new file mode 100644 index 000000000..d95e34f1d --- /dev/null +++ b/shared/models/videos/stats/video-stats-timeserie.model.ts @@ -0,0 +1,6 @@ +export interface VideoStatsTimeserie { + data: { + date: string + value: number + }[] +} -- cgit v1.2.3