From b2d3883bbb1b75b8a55aa26fafef7302a5781fd6 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 24 Sep 2024 15:36:21 -0500 Subject: Use function from `uploader.platforms` package Reuse the function from the `uploader.platforms.models` module. This reduces duplication, and also helps with ensuring robustness of the code — the function actually checks to ensure the platform relates to the selected species. --- uploader/expression_data/dbinsert.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'uploader/expression_data/dbinsert.py') diff --git a/uploader/expression_data/dbinsert.py b/uploader/expression_data/dbinsert.py index b30f730..e746944 100644 --- a/uploader/expression_data/dbinsert.py +++ b/uploader/expression_data/dbinsert.py @@ -15,6 +15,7 @@ from uploader import jobs from uploader.authorisation import require_login from uploader.population.models import populations_by_species from uploader.species.models import all_species, species_by_id +from uploader.platforms.models import platform_by_species_and_id from uploader.db_utils import with_db_connection, database_connection dbinsertbp = Blueprint("dbinsert", __name__) @@ -48,14 +49,6 @@ def genechips(): return {} -def platform_by_id(genechipid:int) -> Union[dict, None]: - "Retrieve the gene platform by id" - with database_connection(app.config["SQL_URI"]) as conn: - with conn.cursor(cursorclass=DictCursor) as cursor: - cursor.execute( - "SELECT * FROM GeneChip WHERE GeneChipId=%s", - (genechipid,)) - return cursor.fetchone() def studies_by_species_and_platform(speciesid:int, genechipid:int) -> tuple: "Retrieve the studies by the related species and gene platform" @@ -347,7 +340,7 @@ def final_confirmation(): with_db_connection(lambda conn: species_by_id(conn, speciesid)), ("SpeciesName", "Name", "MenuName")), platform=selected_keys( - platform_by_id(genechipid), + platform_by_species_and_id(speciesid, genechipid), ("GeneChipName", "Name", "GeoPlatform", "Title", "GO_tree_value")), study=selected_keys( study_by_id(studyid), ("Name", "FullName", "ShortName")), -- cgit v1.2.3