From b7349b5df85a6c9574cab6b1d08b902408b6038e Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Sun, 8 Sep 2024 19:56:44 +0100 Subject: [PATCH] Tried to solve some more issues with counts --- src/utils/groups.be.ts | 5 ++++- src/utils/users.be.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils/groups.be.ts b/src/utils/groups.be.ts index 699f11d6..42fe68f9 100644 --- a/src/utils/groups.be.ts +++ b/src/utils/groups.be.ts @@ -64,7 +64,10 @@ export const getUserNamedGroup = async (id: string, name: string) => { }; export const getUsersGroups = async (ids: string[]) => { - return await db.collection("groups").find({admin: ids}).toArray(); + return await db + .collection("groups") + .find({admin: {$in: ids}}) + .toArray(); }; export const getAllAssignersByCorporate = async (corporateID: string): Promise => { diff --git a/src/utils/users.be.ts b/src/utils/users.be.ts index a04bfd20..cd5c1c1a 100644 --- a/src/utils/users.be.ts +++ b/src/utils/users.be.ts @@ -56,7 +56,7 @@ export async function getLinkedUsers( const participants = uniq([ ...adminGroups.flatMap((x) => x.participants), - ...groups.flat().flatMap((x) => x.participants), + ...(userType === "mastercorporate" ? groups.flat().flatMap((x) => x.participants) : []), ...(userType === "teacher" ? belongingGroups.flatMap((x) => x.participants) : []), ]);