diff options
author | Frederick Muriuki Muriithi | 2023-07-18 13:39:18 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-07-18 13:39:18 +0300 |
commit | beff6962223c1885697c5755878a0b694d210965 (patch) | |
tree | f43d647fbbc834af5c0ce2deacee3b80e8fa3058 /wqflask | |
parent | 82f401cc4dbc65352a368fca76d100e9e773088e (diff) | |
download | genenetwork2-beff6962223c1885697c5755878a0b694d210965.tar.gz |
Replace ORM calls with direct queries
Avoid the use of the ORM code for fetching data from the database, and
instead use direct queries that indicate easily what is being fetched
from the database.
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/metadata_edits.py | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/wqflask/wqflask/metadata_edits.py b/wqflask/wqflask/metadata_edits.py index a3b7f307..9decbc16 100644 --- a/wqflask/wqflask/metadata_edits.py +++ b/wqflask/wqflask/metadata_edits.py @@ -52,6 +52,7 @@ from gn3.db.phenotypes import Phenotype from gn3.db.phenotypes import Probeset from gn3.db.phenotypes import Publication from gn3.db.phenotypes import PublishXRef +from gn3.db.phenotypes import fetch_trait, fetch_metadata, fetch_publication from gn3.db.phenotypes import probeset_mapping from gn3.db.sample_data import delete_sample_data from gn3.db.sample_data import get_trait_sample_data, get_trait_csv_sample_data @@ -92,23 +93,11 @@ def _get_diffs(diff_dir: str, redis_conn: redis.Redis): def edit_phenotype(conn, name, dataset_id): - publish_xref = fetchone( - conn=conn, - table="PublishXRef", - where=PublishXRef(id_=name, inbred_set_id=dataset_id), - ) + publish_xref = fetch_trait(conn, dataset_id=dataset_id, trait_name=name) return { "publish_xref": publish_xref, - "phenotype": fetchone( - conn=conn, - table="Phenotype", - where=Phenotype(id_=publish_xref.phenotype_id), - ), - "publication": fetchone( - conn=conn, - table="Publication", - where=Publication(id_=publish_xref.publication_id), - ), + "phenotype": fetch_metadata(conn, publish_xref["phenotype_id"]), + "publication": fetch_publication(conn, publish_xref["publication_id"]) } @@ -135,7 +124,7 @@ def display_phenotype_metadata(dataset_id: str, name: str): group_name = retrieve_phenotype_group_name(conn, dataset_id) sample_list = retrieve_sample_list(group_name) - sample_data = get_trait_sample_data(conn, name, _d.get("publish_xref").phenotype_id) + sample_data = get_trait_sample_data(conn, name, _d["publish_xref"]["phenotype_id"]) return render_template( "edit_phenotype.html", |