X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo-channel.ts;h=91dafbcf1d996d6b6973d0495bdc1486c9b1a0a3;hb=7b6b445d91d3f0bcbb526cb1e8c1f26b96f0a971;hp=00ae58c68cba89fae24088b626353b16bd4d34cc;hpb=43fc899a101c0fd266cc294dc573b256168bef18;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 00ae58c68..91dafbcf1 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts @@ -311,6 +311,16 @@ export type SummaryOptions = { ')' ), 'viewsPerDay' + ], + [ + literal( + '(' + + 'SELECT COALESCE(SUM("video".views), 0) AS totalViews ' + + 'FROM "video" ' + + 'WHERE "video"."channelId" = "VideoChannelModel"."id"' + + ')' + ), + 'totalViews' ] ] } @@ -419,7 +429,7 @@ export class VideoChannelModel extends ModelActor"."serverId" = "Account->Actor->Server"."id"` }) } + const totalViews = this.get('totalViews') as number + const actor = this.Actor.toFormattedJSON() const videoChannel = { id: this.id, @@ -779,6 +791,7 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"` videosCount, viewsPerDay, + totalViews, avatars: actor.avatars,