]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-channel.ts
Regenerate video filenames on transcoding
[github/Chocobozzz/PeerTube.git] / server / models / video / video-channel.ts
index 00ae58c68cba89fae24088b626353b16bd4d34cc..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'
           ]
         ]
       }
@@ -419,7 +429,7 @@ export class VideoChannelModel extends Model<Partial<AttributesOnly<VideoChannel
       }
     }
 
-    return VideoChannelModel.count(query)
+    return VideoChannelModel.unscoped().count(query)
   }
 
   static async getStats () {
@@ -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,