diff options
author | Chocobozzz <me@florianbigard.com> | 2022-05-18 09:18:39 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-05-18 09:18:39 +0200 |
commit | 305ec384966303bbcedb72b905c5ec4f32d9c7ad (patch) | |
tree | 4e0f722a5f0d4638484cb188c9205e53c11b4e89 /server/models/view/local-video-viewer.ts | |
parent | 0cc253c9719b1e361d33d62adcef4c292cc98be9 (diff) | |
download | PeerTube-305ec384966303bbcedb72b905c5ec4f32d9c7ad.tar.gz PeerTube-305ec384966303bbcedb72b905c5ec4f32d9c7ad.tar.zst PeerTube-305ec384966303bbcedb72b905c5ec4f32d9c7ad.zip |
Add total viewers overall stat
Diffstat (limited to 'server/models/view/local-video-viewer.ts')
-rw-r--r-- | server/models/view/local-video-viewer.ts | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/server/models/view/local-video-viewer.ts b/server/models/view/local-video-viewer.ts index b8c372040..12350861b 100644 --- a/server/models/view/local-video-viewer.ts +++ b/server/models/view/local-video-viewer.ts | |||
@@ -125,6 +125,7 @@ export class LocalVideoViewerModel extends Model<Partial<AttributesOnly<LocalVid | |||
125 | } | 125 | } |
126 | 126 | ||
127 | const watchTimeQuery = `SELECT ` + | 127 | const watchTimeQuery = `SELECT ` + |
128 | `COUNT("localVideoViewer"."id") AS "totalViewers", ` + | ||
128 | `SUM("localVideoViewer"."watchTime") AS "totalWatchTime", ` + | 129 | `SUM("localVideoViewer"."watchTime") AS "totalWatchTime", ` + |
129 | `AVG("localVideoViewer"."watchTime") AS "averageWatchTime" ` + | 130 | `AVG("localVideoViewer"."watchTime") AS "averageWatchTime" ` + |
130 | `FROM "localVideoViewer" ` + | 131 | `FROM "localVideoViewer" ` + |
@@ -177,6 +178,10 @@ export class LocalVideoViewerModel extends Model<Partial<AttributesOnly<LocalVid | |||
177 | ? Math.round(rowsWatchTime[0].averageWatchTime) || 0 | 178 | ? Math.round(rowsWatchTime[0].averageWatchTime) || 0 |
178 | : 0, | 179 | : 0, |
179 | 180 | ||
181 | totalViewers: rowsWatchTime.length !== 0 | ||
182 | ? Math.round(rowsWatchTime[0].totalViewers) || 0 | ||
183 | : 0, | ||
184 | |||
180 | viewersPeak, | 185 | viewersPeak, |
181 | viewersPeakDate: rowsWatchPeak.length !== 0 && viewersPeak !== 0 | 186 | viewersPeakDate: rowsWatchPeak.length !== 0 && viewersPeak !== 0 |
182 | ? rowsWatchPeak[0].dateBreakpoint || null | 187 | ? rowsWatchPeak[0].dateBreakpoint || null |