From fe3a55b071c99b346e9e9ab786f5d219e5a064cd Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 8 Jun 2018 20:34:37 +0200 Subject: Add video comments RSS --- server/models/video/video-comment.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 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 18398905e..353fb1a0e 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts @@ -340,6 +340,28 @@ export class VideoCommentModel extends Model { return VideoCommentModel.findAndCountAll(query) } + static listForFeed (start: number, count: number, videoId?: number) { + const query = { + order: [ [ 'createdAt', 'DESC' ] ], + start, + count, + where: {}, + include: [ + { + attributes: [ 'name' ], + model: VideoModel.unscoped(), + required: true + } + ] + } + + if (videoId) query.where['videoId'] = videoId + + return VideoCommentModel + .scope([ ScopeNames.WITH_ACCOUNT ]) + .findAll(query) + } + static async getStats () { const totalLocalVideoComments = await VideoCommentModel.count({ include: [ -- cgit v1.2.3