diff options
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/view/local-video-viewer.ts | 8 |
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 | } |