Skip to content

Commit

Permalink
refactor: use existing cached member check to return membercount
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed May 6, 2024
1 parent 26f57ef commit ab7e574
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions services/api/src/models/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,16 +539,8 @@ export const Group = (clients: {
const getGroupMemberCount = async (
group: Group
): Promise<number> => {
const roleSubgroups = group.subGroups.filter(isRoleSubgroup);
let membership = 0;
for (const roleSubgroup of roleSubgroups) {
const keycloakUsers = await keycloakAdminClient.groups.listMembers({
id: roleSubgroup.id
});

membership = membership + keycloakUsers.length;
}
return membership;
const membership = await getGroupMembership(group)
return membership.length;
};

const addGroup = async (groupInput: Group, projectId?: number, organizationId?: number): Promise<Group> => {
Expand Down

0 comments on commit ab7e574

Please sign in to comment.