aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-04-08 10:22:56 +0200
committerChocobozzz <chocobozzz@cpy.re>2022-04-15 09:49:35 +0200
commit3eda9b775ae700ac544e8c5588514627796b83cd (patch)
tree97ec1fdfce274e83d976352f5b4154c315ee33d7 /server/models
parent901bcf5c188ea79350fecd499ad76460b866617b (diff)
downloadPeerTube-3eda9b775ae700ac544e8c5588514627796b83cd.tar.gz
PeerTube-3eda9b775ae700ac544e8c5588514627796b83cd.tar.zst
PeerTube-3eda9b775ae700ac544e8c5588514627796b83cd.zip
Support interactive video stats graph
Diffstat (limited to 'server/models')
-rw-r--r--server/models/view/local-video-viewer.ts8
1 files changed, 4 insertions, 4 deletions
diff --git a/server/models/view/local-video-viewer.ts b/server/models/view/local-video-viewer.ts
index ad2ad35ca..b6ddcbb57 100644
--- a/server/models/view/local-video-viewer.ts
+++ b/server/models/view/local-video-viewer.ts
@@ -221,7 +221,7 @@ export class LocalVideoViewerModel extends Model<Partial<AttributesOnly<LocalVid
221 }): Promise<VideoStatsTimeserie> { 221 }): Promise<VideoStatsTimeserie> {
222 const { video, metric } = options 222 const { video, metric } = options
223 223
224 const { groupInterval, sqlInterval, startDate, endDate } = buildGroupByAndBoundaries(options.startDate, options.endDate) 224 const { groupInterval, startDate, endDate } = buildGroupByAndBoundaries(options.startDate, options.endDate)
225 225
226 const selectMetrics: { [ id in VideoStatsTimeserieMetric ]: string } = { 226 const selectMetrics: { [ id in VideoStatsTimeserieMetric ]: string } = {
227 viewers: 'COUNT("localVideoViewer"."id")', 227 viewers: 'COUNT("localVideoViewer"."id")',
@@ -230,9 +230,9 @@ export class LocalVideoViewerModel extends Model<Partial<AttributesOnly<LocalVid
230 230
231 const query = `WITH "intervals" AS ( 231 const query = `WITH "intervals" AS (
232 SELECT 232 SELECT
233 "time" AS "startDate", "time" + :sqlInterval::interval as "endDate" 233 "time" AS "startDate", "time" + :groupInterval::interval as "endDate"
234 FROM 234 FROM
235 generate_series(:startDate::timestamptz, :endDate::timestamptz, :sqlInterval::interval) serie("time") 235 generate_series(:startDate::timestamptz, :endDate::timestamptz, :groupInterval::interval) serie("time")
236 ) 236 )
237 SELECT "intervals"."startDate" as "date", COALESCE(${selectMetrics[metric]}, 0) AS value 237 SELECT "intervals"."startDate" as "date", COALESCE(${selectMetrics[metric]}, 0) AS value
238 FROM 238 FROM
@@ -249,7 +249,7 @@ export class LocalVideoViewerModel extends Model<Partial<AttributesOnly<LocalVid
249 replacements: { 249 replacements: {
250 startDate, 250 startDate,
251 endDate, 251 endDate,
252 sqlInterval, 252 groupInterval,
253 videoId: video.id 253 videoId: video.id
254 } 254 }
255 } 255 }