From adc94cf09c86112051f72055852efcc977e4a04a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 27 Jul 2022 16:19:25 +0200 Subject: Add live and viewers otel metrics --- server/models/video/video.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'server/models') diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 27e605be6..924f12a5e 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -1209,18 +1209,21 @@ export class VideoModel extends Model>> { return VideoModel.getAvailableForApi(queryOptions) } - static countLocalLives () { - const options = { + static countLives (options: { + remote: boolean + mode: 'published' | 'not-ended' + }) { + const query = { where: { - remote: false, + remote: options.remote, isLive: true, - state: { - [Op.ne]: VideoState.LIVE_ENDED - } + state: options.mode === 'not-ended' + ? { [Op.ne]: VideoState.LIVE_ENDED } + : { [Op.eq]: VideoState.PUBLISHED } } } - return VideoModel.count(options) + return VideoModel.count(query) } static countVideosUploadedByUserSince (userId: number, since: Date) { -- cgit v1.2.3