aboutsummaryrefslogtreecommitdiff
path: root/gn3/auth/authorisation/groups
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-02-24 12:30:36 +0300
committerFrederick Muriuki Muriithi2023-02-24 12:34:11 +0300
commit32a9103fba0454338ad126125038d97e7d228ec5 (patch)
tree9f9f10ab722598503c1398bd169c01bc7f962501 /gn3/auth/authorisation/groups
parentd6499ce9f64d6f71d389e2ad32b112147a2f162a (diff)
downloadgenenetwork3-32a9103fba0454338ad126125038d97e7d228ec5.tar.gz
auth: resources: Fix query for data not linked to resources
Diffstat (limited to 'gn3/auth/authorisation/groups')
-rw-r--r--gn3/auth/authorisation/groups/views.py13
1 files changed, 8 insertions, 5 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)