diff options
author | Florian CUNY <poslovitch@bentobox.world> | 2022-05-31 16:01:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-31 16:01:11 +0200 |
commit | c6f8ca4d6596572de981162983bd02eb2613791d (patch) | |
tree | f2ff530c1e1888202d0208837dfc928f1388a6e3 /server/models/video | |
parent | b0185d7351f71bbc5ccbeed5bba86a619a7de70b (diff) | |
download | PeerTube-c6f8ca4d6596572de981162983bd02eb2613791d.tar.gz PeerTube-c6f8ca4d6596572de981162983bd02eb2613791d.tar.zst PeerTube-c6f8ca4d6596572de981162983bd02eb2613791d.zip |
Added "total views" in the my channels list (#5007)
* Added "total views" in the my channels list
Implements https://github.com/Chocobozzz/PeerTube/issues/4331
* Fix lint
* applied suggested change
* updated openAPI spec for the use "withStats" when getting video channels
* applied code change
* removed GROUP BY in query
* Fixed test
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/video-channel.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index d6dd1b8bb..91dafbcf1 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts | |||
@@ -311,6 +311,16 @@ export type SummaryOptions = { | |||
311 | ')' | 311 | ')' |
312 | ), | 312 | ), |
313 | 'viewsPerDay' | 313 | 'viewsPerDay' |
314 | ], | ||
315 | [ | ||
316 | literal( | ||
317 | '(' + | ||
318 | 'SELECT COALESCE(SUM("video".views), 0) AS totalViews ' + | ||
319 | 'FROM "video" ' + | ||
320 | 'WHERE "video"."channelId" = "VideoChannelModel"."id"' + | ||
321 | ')' | ||
322 | ), | ||
323 | 'totalViews' | ||
314 | ] | 324 | ] |
315 | ] | 325 | ] |
316 | } | 326 | } |
@@ -766,6 +776,8 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"` | |||
766 | }) | 776 | }) |
767 | } | 777 | } |
768 | 778 | ||
779 | const totalViews = this.get('totalViews') as number | ||
780 | |||
769 | const actor = this.Actor.toFormattedJSON() | 781 | const actor = this.Actor.toFormattedJSON() |
770 | const videoChannel = { | 782 | const videoChannel = { |
771 | id: this.id, | 783 | id: this.id, |
@@ -779,6 +791,7 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"` | |||
779 | 791 | ||
780 | videosCount, | 792 | videosCount, |
781 | viewsPerDay, | 793 | viewsPerDay, |
794 | totalViews, | ||
782 | 795 | ||
783 | avatars: actor.avatars, | 796 | avatars: actor.avatars, |
784 | 797 | ||