Skip to content

Commit

Permalink
Merge pull request uselagoon#3719 from uselagoon/refactor-group-membe…
Browse files Browse the repository at this point in the history
…rcount

refactor: use existing cached member check to return membercount
  • Loading branch information
shreddedbacon authored May 7, 2024
2 parents 18d528a + ab7e574 commit b470e13
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 b470e13

Please sign in to comment.