aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video')
-rw-r--r--server/models/video/video-comment.ts26
-rw-r--r--server/models/video/video.ts23
2 files changed, 49 insertions, 0 deletions
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts
index 47e3211a3..bf8da924d 100644
--- a/server/models/video/video-comment.ts
+++ b/server/models/video/video-comment.ts
@@ -326,6 +326,32 @@ export class VideoCommentModel extends Model<VideoCommentModel> {
326 .findAll(query) 326 .findAll(query)
327 } 327 }
328 328
329 static async getStats () {
330 const totalLocalVideoComments = await VideoCommentModel.count({
331 include: [
332 {
333 model: AccountModel,
334 required: true,
335 include: [
336 {
337 model: ActorModel,
338 required: true,
339 where: {
340 serverId: null
341 }
342 }
343 ]
344 }
345 ]
346 })
347 const totalVideoComments = await VideoCommentModel.count()
348
349 return {
350 totalLocalVideoComments,
351 totalVideoComments
352 }
353 }
354
329 getThreadId (): number { 355 getThreadId (): number {
330 return this.originCommentId || this.id 356 return this.originCommentId || this.id
331 } 357 }
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