diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/models/video/video-comment.ts | 12 |
1 files changed, 12 insertions, 0 deletions
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 { | |||
56 | ')' | 56 | ')' |
57 | ), | 57 | ), |
58 | 'totalReplies' | 58 | 'totalReplies' |
59 | ], | ||
60 | [ | ||
61 | Sequelize.literal( | ||
62 | '(' + | ||
63 | 'SELECT COUNT("replies"."id") ' + | ||
64 | 'FROM "videoComment" AS "replies" ' + | ||
65 | 'WHERE "replies"."originCommentId" = "VideoCommentModel"."id" ' + | ||
66 | 'AND "accountId" = ' + userAccountId + | ||
67 | ')' | ||
68 | ), | ||
69 | 'totalRepliesFromVideoAuthor' | ||
59 | ] | 70 | ] |
60 | ] | 71 | ] |
61 | } | 72 | } |
@@ -501,6 +512,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> { | |||
501 | updatedAt: this.updatedAt, | 512 | updatedAt: this.updatedAt, |
502 | deletedAt: this.deletedAt, | 513 | deletedAt: this.deletedAt, |
503 | isDeleted: this.isDeleted(), | 514 | isDeleted: this.isDeleted(), |
515 | totalRepliesFromVideoAuthor: this.get('totalRepliesFromVideoAuthor') || 0, | ||
504 | totalReplies: this.get('totalReplies') || 0, | 516 | totalReplies: this.get('totalReplies') || 0, |
505 | account: this.Account ? this.Account.toFormattedJSON() : null | 517 | account: this.Account ? this.Account.toFormattedJSON() : null |
506 | } as VideoComment | 518 | } as VideoComment |