From 00f863b3dcb76f5fdca8e139e903e2f7edb861fc Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 3 Oct 2024 13:35:52 -0500 Subject: BugFix: Remove duplicates from resources list Issue: https://issues.genenetwork.org/issues/gn-auth/resources-duplicates-in-resources-list The query was returning multiple instances of the same resource in situations where a user had more than one role of a particular resource. --- gn_auth/auth/authorisation/resources/models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'gn_auth') diff --git a/gn_auth/auth/authorisation/resources/models.py b/gn_auth/auth/authorisation/resources/models.py index 8d3cfc3..c1748f1 100644 --- a/gn_auth/auth/authorisation/resources/models.py +++ b/gn_auth/auth/authorisation/resources/models.py @@ -133,8 +133,10 @@ def user_resources(conn: db.DbConnection, user: User) -> Sequence[Resource]: """List the resources available to the user""" with db.cursor(conn) as cursor: cursor.execute( - ("SELECT r.*, rc.resource_category_key, " - "rc.resource_category_description FROM user_roles AS ur " + ("SELECT DISTINCT(r.resource_id), r.resource_name, " + "r.resource_category_id, r.public, rc.resource_category_key, " + "rc.resource_category_description " + "FROM user_roles AS ur " "INNER JOIN resources AS r ON ur.resource_id=r.resource_id " "INNER JOIN resource_categories AS rc " "ON r.resource_category_id=rc.resource_category_id " -- cgit v1.2.3