Skip to content

Commit

Permalink
fix collection userSolvedCount bug
Browse files Browse the repository at this point in the history
  • Loading branch information
sspenst committed May 17, 2024
1 parent 9ebba12 commit 4b41c8d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pages/api/collection-by-id/[id].ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ export async function getCollection(props: GetCollectionProps): Promise<Collecti
export async function getCollections({
includeDraft,
matchQuery,
reqUser,
populateAroundId,
populateAroundSlug,
populateLevelData = true,
populateLevelDirection,
reqUser,
}: GetCollectionProps): Promise<Collection[]> {
const populateLevelCount = 5;
const collectionAgg = await CollectionModel.aggregate<EnrichedCollection>(([
Expand Down Expand Up @@ -208,7 +208,13 @@ export async function getCollections({
$size: '$levels'
},
userSolvedCount: {
$sum: '$levels.complete'
$size: {
$filter: {
input: '$levels',
as: 'level',
cond: { $eq: ['$$level.complete', true] }
}
}
}
}
},
Expand Down

0 comments on commit 4b41c8d

Please sign in to comment.