Skip to content

Commit

Permalink
Merge branch 'development' into dojo/replicate_action_refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
nshandra committed Dec 16, 2024
2 parents 8cddb03 + 90f1dd0 commit a923088
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/data/repositories/UserD2ApiRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,20 @@ export class UserD2ApiRepository implements UserRepository {
const allUsersGroups = this.buildUsersByGroupId(users);
const allExistingUsersGroups = this.buildUsersByGroupId(existing);

const existingKeys = _(allExistingUsersGroups).keys().value();

const groupsIdsToAdd = users.flatMap(user => {
return user.userGroups.map(userGroup => ({ id: userGroup.id }));
const groupsRef = user.userGroups.map(userGroup => ({ id: userGroup.id }));
return groupsRef.filter(({ id }) => !existingKeys.includes(id));
});

const groupsIdsToDelete = users.flatMap(user => {
const existingUser = existing.find(({ id }) => id === user.id);
const difference = _.differenceWith(existingUser?.userGroups, user.userGroups, _.isEqual);
const difference = _.differenceWith(
existingUser?.userGroups,
user.userGroups,
(user1, user2) => user1.id === user2.id
);
return difference.map(userGroup => ({ id: userGroup.id }));
});

Expand Down

0 comments on commit a923088

Please sign in to comment.