From 09cababd79f9d445aa027c93cdfe823745fa041a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 28 Feb 2018 18:04:46 +0100 Subject: Add stats route --- server/models/video/video-comment.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'server/models/video/video-comment.ts') 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 { .findAll(query) } + static async getStats () { + const totalLocalVideoComments = await VideoCommentModel.count({ + include: [ + { + model: AccountModel, + required: true, + include: [ + { + model: ActorModel, + required: true, + where: { + serverId: null + } + } + ] + } + ] + }) + const totalVideoComments = await VideoCommentModel.count() + + return { + totalLocalVideoComments, + totalVideoComments + } + } + getThreadId (): number { return this.originCommentId || this.id } -- cgit v1.2.3