From 9a0c6fd1759e13fa7a934852f87e9aa4c62d7dfd Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 19 Apr 2023 14:42:31 +0300 Subject: auth: Setup selected traits correctly Fix bugs with setting up of the selected traits for use while filtering the search results. --- scripts/search_phenotypes.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/search_phenotypes.py b/scripts/search_phenotypes.py index 7049834..2f7fcf3 100644 --- a/scripts/search_phenotypes.py +++ b/scripts/search_phenotypes.py @@ -11,6 +11,7 @@ from datetime import datetime, timedelta import click import redis import requests +from MySQLdb.cursors import DictCursor from gn3 import jobs from gn3.auth import db as authdb @@ -92,13 +93,13 @@ def search(# pylint: disable=[too-many-arguments, too-many-locals] try: search_query = f"species:{species}" + ( f" AND ({query})" if bool(query) else "") - filter_keys = ("SpeciesName", "InbredSetName", "dataset_name", - "PublishXRefId") - selected_traits = tuple(tuple(item[key] for key in filter_keys) - for item in json.loads(selected)) - linked = tuple(tuple(row[key] for key in filter_keys) - for row in linked_phenotype_data( - authconn, gn3conn, species)) + selected_traits = tuple( + (item["species"], item["group"], item["dataset"], item["name"]) + for item in json.loads(selected)) + linked = tuple( + (row["SpeciesName"], row["InbredSetName"], row["dataset_name"], + row["PublishXRefId"]) + for row in linked_phenotype_data(authconn, gn3conn, species)) page = 1 count = 0 while count < per_page: -- cgit v1.2.3