- [ScopeNames.ATTRIBUTES_FOR_API]: (blockerAccountIds: number[]) => {
- return {
- attributes: {
- include: [
- [
- Sequelize.literal(
- '(' +
- 'WITH "blocklist" AS (' + buildBlockedAccountSQL(blockerAccountIds) + ')' +
- 'SELECT COUNT("replies"."id") - (' +
- 'SELECT COUNT("replies"."id") ' +
- 'FROM "videoComment" AS "replies" ' +
- 'WHERE "replies"."originCommentId" = "VideoCommentModel"."id" ' +
- 'AND "accountId" IN (SELECT "id" FROM "blocklist")' +
- ')' +
- 'FROM "videoComment" AS "replies" ' +
- 'WHERE "replies"."originCommentId" = "VideoCommentModel"."id" ' +
- 'AND "accountId" NOT IN (SELECT "id" FROM "blocklist")' +
- ')'
- ),
- 'totalReplies'
- ],
- [
- Sequelize.literal(
- '(' +
- 'SELECT COUNT("replies"."id") ' +
- 'FROM "videoComment" AS "replies" ' +
- 'INNER JOIN "video" ON "video"."id" = "replies"."videoId" ' +
- 'INNER JOIN "videoChannel" ON "videoChannel"."id" = "video"."channelId" ' +
- 'WHERE "replies"."originCommentId" = "VideoCommentModel"."id" ' +
- 'AND "replies"."accountId" = "videoChannel"."accountId"' +
- ')'
- ),
- 'totalRepliesFromVideoAuthor'
- ]
- ]
- }
- } as FindOptions
- },