diff --git a/pages/api/collection-by-id/[id].ts b/pages/api/collection-by-id/[id].ts index c6f792ee1..9d0a0ee10 100644 --- a/pages/api/collection-by-id/[id].ts +++ b/pages/api/collection-by-id/[id].ts @@ -70,11 +70,11 @@ export async function getCollection(props: GetCollectionProps): Promise { const populateLevelCount = 5; const collectionAgg = await CollectionModel.aggregate(([ @@ -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] } + } + } } } },