aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/view
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/view')
-rw-r--r--server/models/view/local-video-viewer.ts12
1 files changed, 7 insertions, 5 deletions
diff --git a/server/models/view/local-video-viewer.ts b/server/models/view/local-video-viewer.ts
index 2862f8b96..2305c7262 100644
--- a/server/models/view/local-video-viewer.ts
+++ b/server/models/view/local-video-viewer.ts
@@ -136,7 +136,7 @@ export class LocalVideoViewerModel extends Model<Partial<AttributesOnly<LocalVid
136 const watchPeakQuery = `WITH "watchPeakValues" AS ( 136 const watchPeakQuery = `WITH "watchPeakValues" AS (
137 SELECT "startDate" AS "dateBreakpoint", 1 AS "inc" 137 SELECT "startDate" AS "dateBreakpoint", 1 AS "inc"
138 FROM "localVideoViewer" 138 FROM "localVideoViewer"
139 WHERE "videoId" = :videoId 139 WHERE "videoId" = :videoId ${dateWhere}
140 UNION ALL 140 UNION ALL
141 SELECT "endDate" AS "dateBreakpoint", -1 AS "inc" 141 SELECT "endDate" AS "dateBreakpoint", -1 AS "inc"
142 FROM "localVideoViewer" 142 FROM "localVideoViewer"
@@ -165,6 +165,10 @@ export class LocalVideoViewerModel extends Model<Partial<AttributesOnly<LocalVid
165 countriesPromise 165 countriesPromise
166 ]) 166 ])
167 167
168 const viewersPeak = rowsWatchPeak.length !== 0
169 ? parseInt(rowsWatchPeak[0].concurrent) || 0
170 : 0
171
168 return { 172 return {
169 totalWatchTime: rowsWatchTime.length !== 0 173 totalWatchTime: rowsWatchTime.length !== 0
170 ? Math.round(rowsWatchTime[0].totalWatchTime) || 0 174 ? Math.round(rowsWatchTime[0].totalWatchTime) || 0
@@ -173,10 +177,8 @@ export class LocalVideoViewerModel extends Model<Partial<AttributesOnly<LocalVid
173 ? Math.round(rowsWatchTime[0].averageWatchTime) || 0 177 ? Math.round(rowsWatchTime[0].averageWatchTime) || 0
174 : 0, 178 : 0,
175 179
176 viewersPeak: rowsWatchPeak.length !== 0 180 viewersPeak,
177 ? parseInt(rowsWatchPeak[0].concurrent) || 0 181 viewersPeakDate: rowsWatchPeak.length !== 0 && viewersPeak !== 0
178 : 0,
179 viewersPeakDate: rowsWatchPeak.length !== 0
180 ? rowsWatchPeak[0].dateBreakpoint || null 182 ? rowsWatchPeak[0].dateBreakpoint || null
181 : null, 183 : null,
182 184