Skip to content

Commit

Permalink
fix: Refactor function to use a dictionary for storing unique users
Browse files Browse the repository at this point in the history
  • Loading branch information
gcharest authored Apr 26, 2024
1 parent 692d6c1 commit e600885
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions app/modules/provisioning/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@ def get_unique_users_from_groups(groups, key):
Returns:
list: A list of unique users from the groups
"""
users = set()
users_dict = {}
if isinstance(groups, list):
for group in groups:
group_users = filter_tools.get_nested_value(group, key)
if group_users:
users.update(str(user) for user in group_users)
for user in filter_tools.get_nested_value(group, key):
if user:
users_dict[str(user)] = user
elif isinstance(groups, dict):
group_users = filter_tools.get_nested_value(groups, key)
if group_users:
users.update(str(user) for user in group_users)
return [eval(user) for user in users]
for user in filter_tools.get_nested_value(groups, key):
if user:
users_dict[str(user)] = user

return list(users_dict.values())


# def sync(source, target, **kwargs):
Expand Down

0 comments on commit e600885

Please sign in to comment.