]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-channel.ts
Merge branch 'release/4.3.0' into develop
[github/Chocobozzz/PeerTube.git] / server / models / video / video-channel.ts
index d6dd1b8bbca6bec237cbf7540627399425d8b3ee..91dafbcf1d996d6b6973d0495bdc1486c9b1a0a3 100644 (file)
@@ -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'
           ]
         ]
       }
@@ -766,6 +776,8 @@ ON              "Account->Actor"."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,