- return VideoCommentModel
- .scope(scopes)
- .findAndCountAll(query)
- .then(({ rows, count }) => {
- return { total: count, data: rows }
- })
+ const countScopesList: ScopeOptions[] = [
+ {
+ method: [ ScopeNames.ATTRIBUTES_FOR_API, blockerAccountIds ]
+ }
+ ]
+
+ const notDeletedQueryCount = {
+ where: {
+ videoId,
+ deletedAt: null,
+ ...accountBlockedWhere
+ }
+ }
+
+ return Promise.all([
+ VideoCommentModel.scope(findScopesList).findAll(queryList),
+ VideoCommentModel.scope(countScopesList).count(queryList),
+ VideoCommentModel.count(notDeletedQueryCount)
+ ]).then(([ rows, count, totalNotDeletedComments ]) => {
+ return { total: count, data: rows, totalNotDeletedComments }
+ })