diff options
author | Chocobozzz <me@florianbigard.com> | 2022-05-24 09:16:42 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-05-24 09:16:42 +0200 |
commit | a65858746c1d2904bf117e8d91816e752d4b94c4 (patch) | |
tree | 1734d54d535d94af627383a6186b357f031beb45 /server/models | |
parent | 21393652621efba8a95715c6f340515d58599ec6 (diff) | |
download | PeerTube-a65858746c1d2904bf117e8d91816e752d4b94c4.tar.gz PeerTube-a65858746c1d2904bf117e8d91816e752d4b94c4.tar.zst PeerTube-a65858746c1d2904bf117e8d91816e752d4b94c4.zip |
Fix my videos total counter
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/video/video.ts | 10 |
1 files changed, 6 insertions, 4 deletions
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<Partial<AttributesOnly<VideoModel>>> { | |||
972 | }) { | 972 | }) { |
973 | const { accountId, channelId, start, count, sort, search, isLive } = options | 973 | const { accountId, channelId, start, count, sort, search, isLive } = options |
974 | 974 | ||
975 | function buildBaseQuery (): FindOptions { | 975 | function buildBaseQuery (forCount: boolean): FindOptions { |
976 | const where: WhereOptions = {} | 976 | const where: WhereOptions = {} |
977 | 977 | ||
978 | if (search) { | 978 | if (search) { |
@@ -1001,7 +1001,9 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> { | |||
1001 | where: channelWhere, | 1001 | where: channelWhere, |
1002 | include: [ | 1002 | include: [ |
1003 | { | 1003 | { |
1004 | model: AccountModel, | 1004 | model: forCount |
1005 | ? AccountModel.unscoped() | ||
1006 | : AccountModel, | ||
1005 | where: { | 1007 | where: { |
1006 | id: accountId | 1008 | id: accountId |
1007 | }, | 1009 | }, |
@@ -1015,8 +1017,8 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> { | |||
1015 | return baseQuery | 1017 | return baseQuery |
1016 | } | 1018 | } |
1017 | 1019 | ||
1018 | const countQuery = buildBaseQuery() | 1020 | const countQuery = buildBaseQuery(true) |
1019 | const findQuery = buildBaseQuery() | 1021 | const findQuery = buildBaseQuery(false) |
1020 | 1022 | ||
1021 | const findScopes: (string | ScopeOptions)[] = [ | 1023 | const findScopes: (string | ScopeOptions)[] = [ |
1022 | ScopeNames.WITH_SCHEDULED_UPDATE, | 1024 | ScopeNames.WITH_SCHEDULED_UPDATE, |