diff options
author | Frederick Muriuki Muriithi | 2023-02-24 12:30:36 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-02-24 12:34:11 +0300 |
commit | 32a9103fba0454338ad126125038d97e7d228ec5 (patch) | |
tree | 9f9f10ab722598503c1398bd169c01bc7f962501 /gn3 | |
parent | d6499ce9f64d6f71d389e2ad32b112147a2f162a (diff) | |
download | genenetwork3-32a9103fba0454338ad126125038d97e7d228ec5.tar.gz |
auth: resources: Fix query for data not linked to resources
Diffstat (limited to 'gn3')
-rw-r--r-- | gn3/auth/authorisation/groups/views.py | 13 | ||||
-rw-r--r-- | gn3/auth/authorisation/resources/models.py | 1 |
2 files changed, 8 insertions, 6 deletions
diff --git a/gn3/auth/authorisation/groups/views.py b/gn3/auth/authorisation/groups/views.py index d21466c..0e779eb 100644 --- a/gn3/auth/authorisation/groups/views.py +++ b/gn3/auth/authorisation/groups/views.py @@ -163,19 +163,22 @@ def unlinked_data(resource_type: str) -> Response: "SELECT group_id, dataset_type, " "trait_id AS dataset_or_trait_id FROM phenotype_resources") - ids_query = ("SELECT group_id, dataset_type, dataset_or_trait_id " - "FROM linked_group_data " - f"{type_filter} " - f"EXCEPT {except_filter} ") + ids_query = ( + "SELECT * FROM (" + "SELECT group_id, dataset_type, dataset_or_trait_id " + "FROM linked_group_data " + f"EXCEPT SELECT * FROM ({except_filter})" + f") {type_filter}") cursor.execute(ids_query) ids = cursor.fetchall() + print(f"THE IDS: {ids} ==> {type_filter}") if ids: clause = ", ".join(["(?, ?, ?)"] * len(ids)) data_query = ( "SELECT * FROM linked_group_data " "WHERE (group_id, dataset_type, dataset_or_trait_id) " - f"IN (VALUES {clause})") + f"IN (VALUES {clause}) ") params = tuple(item for sublist in ((row[0], row[1], row[2]) for row in ids) for item in sublist) diff --git a/gn3/auth/authorisation/resources/models.py b/gn3/auth/authorisation/resources/models.py index d3023ac..3547bc6 100644 --- a/gn3/auth/authorisation/resources/models.py +++ b/gn3/auth/authorisation/resources/models.py @@ -207,7 +207,6 @@ def attach_resource_data(cursor: db.DbCursor, resource: Resource) -> Resource: dict(data_row) for data_row in resource_data_function[category.resource_category_key]( cursor, resource.resource_id)) - print(f"DATA ROWS: {data_rows}") return Resource( resource.group, resource.resource_id, resource.resource_name, resource.resource_category, resource.public, data_rows) |