Skip to content

Commit

Permalink
Remove duplicate apps for common group (nebari-dev#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
aktech authored Jul 12, 2024
1 parent f803a3b commit 734d7f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion jhub_apps/service/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ def get_shared_servers(current_hub_user):
user_servers_without_default_jlab = list(filter(lambda server: server["name"] != "", all_users_servers))
hub_client_user = HubClient(username=current_hub_user['name'])
shared_servers = hub_client_user.get_shared_servers()
shared_server_names = {shared_server["server"]["name"] for shared_server in shared_servers}
shared_server_names = {
shared_server["server"]["name"] for shared_server in shared_servers
# remove shared apps by current user
if shared_server["server"]["user"]["name"] != current_hub_user['name']
}
shared_servers_rich = [
server for server in user_servers_without_default_jlab
if server["name"] in shared_server_names
Expand Down
6 changes: 4 additions & 2 deletions jhub_apps/tests/tests_unit/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,10 @@ def test_shared_server_filtering(hub_get_shared_servers, get_users):
}
]
hub_get_shared_servers.return_value = [
{"server": {"name": "panel-56"}},
{"server": {"name": "panel-34"}},
{"server": {"name": "panel-56", "user": {"name": "another-user"}}},
{"server": {"name": "panel-34", "user": {"name": "another-user"}}},
{"server": {"name": "panel-23", "user": {"name": "fakeuser"}}},
{"server": {"name": "panel-42", "user": {"name": "fakeuser"}}},
]
shared_servers = get_shared_servers(current_hub_user)
assert shared_servers == [
Expand Down

0 comments on commit 734d7f0

Please sign in to comment.