diff options
author | Chocobozzz <me@florianbigard.com> | 2022-07-27 16:19:25 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-07-27 16:19:25 +0200 |
commit | adc94cf09c86112051f72055852efcc977e4a04a (patch) | |
tree | ae6f25824c1e66004fa69aa9f685642d8d7ad8b4 /server/models/video | |
parent | 50cc1ee48aacb6e7d6513c0f108492a589b515ea (diff) | |
download | PeerTube-adc94cf09c86112051f72055852efcc977e4a04a.tar.gz PeerTube-adc94cf09c86112051f72055852efcc977e4a04a.tar.zst PeerTube-adc94cf09c86112051f72055852efcc977e4a04a.zip |
Add live and viewers otel metrics
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/video.ts | 17 |
1 files changed, 10 insertions, 7 deletions
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<Partial<AttributesOnly<VideoModel>>> { | |||
1209 | return VideoModel.getAvailableForApi(queryOptions) | 1209 | return VideoModel.getAvailableForApi(queryOptions) |
1210 | } | 1210 | } |
1211 | 1211 | ||
1212 | static countLocalLives () { | 1212 | static countLives (options: { |
1213 | const options = { | 1213 | remote: boolean |
1214 | mode: 'published' | 'not-ended' | ||
1215 | }) { | ||
1216 | const query = { | ||
1214 | where: { | 1217 | where: { |
1215 | remote: false, | 1218 | remote: options.remote, |
1216 | isLive: true, | 1219 | isLive: true, |
1217 | state: { | 1220 | state: options.mode === 'not-ended' |
1218 | [Op.ne]: VideoState.LIVE_ENDED | 1221 | ? { [Op.ne]: VideoState.LIVE_ENDED } |
1219 | } | 1222 | : { [Op.eq]: VideoState.PUBLISHED } |
1220 | } | 1223 | } |
1221 | } | 1224 | } |
1222 | 1225 | ||
1223 | return VideoModel.count(options) | 1226 | return VideoModel.count(query) |
1224 | } | 1227 | } |
1225 | 1228 | ||
1226 | static countVideosUploadedByUserSince (userId: number, since: Date) { | 1229 | static countVideosUploadedByUserSince (userId: number, since: Date) { |