aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-28 18:04:46 +0100
committerChocobozzz <me@florianbigard.com>2018-02-28 18:04:55 +0100
commit09cababd79f9d445aa027c93cdfe823745fa041a (patch)
treef781d6ba78b5c4ce7220dea55f13b21230f203d6 /server/models/video/video.ts
parent22b59e8099947605085cf65a440f07f37fce6b65 (diff)
downloadPeerTube-09cababd79f9d445aa027c93cdfe823745fa041a.tar.gz
PeerTube-09cababd79f9d445aa027c93cdfe823745fa041a.tar.zst
PeerTube-09cababd79f9d445aa027c93cdfe823745fa041a.zip
Add stats route
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r--server/models/video/video.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 80ca513bf..f6a21814c 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -761,6 +761,29 @@ export class VideoModel extends Model<VideoModel> {
761 .findOne(options) 761 .findOne(options)
762 } 762 }
763 763
764 static async getStats () {
765 const totalLocalVideos = await VideoModel.count({
766 where: {
767 remote: false
768 }
769 })
770 const totalVideos = await VideoModel.count()
771
772 let totalLocalVideoViews = await VideoModel.sum('views', {
773 where: {
774 remote: false
775 }
776 })
777 // Sequelize could return null...
778 if (!totalLocalVideoViews) totalLocalVideoViews = 0
779
780 return {
781 totalLocalVideos,
782 totalLocalVideoViews,
783 totalVideos
784 }
785 }
786
764 getOriginalFile () { 787 getOriginalFile () {
765 if (Array.isArray(this.VideoFiles) === false) return undefined 788 if (Array.isArray(this.VideoFiles) === false) return undefined
766 789