From 5b0413ddaa7949a6a44512a8281c5a23466599ae Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Sat, 28 Dec 2019 11:27:31 +0100 Subject: Add author indicator to the comment replies loader --- server/models/video/video-comment.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'server/models/video') diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts index 28f011b03..c2798e82a 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts @@ -56,6 +56,17 @@ enum ScopeNames { ')' ), 'totalReplies' + ], + [ + Sequelize.literal( + '(' + + 'SELECT COUNT("replies"."id") ' + + 'FROM "videoComment" AS "replies" ' + + 'WHERE "replies"."originCommentId" = "VideoCommentModel"."id" ' + + 'AND "accountId" = ' + userAccountId + + ')' + ), + 'totalRepliesFromVideoAuthor' ] ] } @@ -501,6 +512,7 @@ export class VideoCommentModel extends Model { updatedAt: this.updatedAt, deletedAt: this.deletedAt, isDeleted: this.isDeleted(), + totalRepliesFromVideoAuthor: this.get('totalRepliesFromVideoAuthor') || 0, totalReplies: this.get('totalReplies') || 0, account: this.Account ? this.Account.toFormattedJSON() : null } as VideoComment -- cgit v1.2.3