From a65858746c1d2904bf117e8d91816e752d4b94c4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 24 May 2022 09:16:42 +0200 Subject: Fix my videos total counter --- server/models/video/video.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'server/models') diff --git a/server/models/video/video.ts b/server/models/video/video.ts index d216ed47d..e6a8d3f95 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -972,7 +972,7 @@ export class VideoModel extends Model>> { }) { const { accountId, channelId, start, count, sort, search, isLive } = options - function buildBaseQuery (): FindOptions { + function buildBaseQuery (forCount: boolean): FindOptions { const where: WhereOptions = {} if (search) { @@ -1001,7 +1001,9 @@ export class VideoModel extends Model>> { where: channelWhere, include: [ { - model: AccountModel, + model: forCount + ? AccountModel.unscoped() + : AccountModel, where: { id: accountId }, @@ -1015,8 +1017,8 @@ export class VideoModel extends Model>> { return baseQuery } - const countQuery = buildBaseQuery() - const findQuery = buildBaseQuery() + const countQuery = buildBaseQuery(true) + const findQuery = buildBaseQuery(false) const findScopes: (string | ScopeOptions)[] = [ ScopeNames.WITH_SCHEDULED_UPDATE, -- cgit v1.2.3