diff options
author | Frederick Muriuki Muriithi | 2024-01-08 05:50:24 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-01-08 05:52:07 +0300 |
commit | 951c3c2fd343eec4b3743ac313ad6ce49082dda3 (patch) | |
tree | b215b0b79b1bea5e8a51bd9d37033ed0b47a5fa8 /qc_app/dbinsert.py | |
parent | cace7a50a45c6d227bce52569fcfc2944fbcbe92 (diff) | |
download | gn-uploader-951c3c2fd343eec4b3743ac313ad6ce49082dda3.tar.gz |
Use extracted functions and fix bugs
Diffstat (limited to 'qc_app/dbinsert.py')
-rw-r--r-- | qc_app/dbinsert.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/qc_app/dbinsert.py b/qc_app/dbinsert.py index 881c913..a878ff5 100644 --- a/qc_app/dbinsert.py +++ b/qc_app/dbinsert.py @@ -11,8 +11,10 @@ from flask import ( flash, request, url_for, Blueprint, redirect, render_template, current_app as app) +from qc_app.db_utils import with_db_connection, database_connection +from qc_app.db import species, species_by_id, populations_by_species + from . import jobs -from .db_utils import with_db_connection, database_connection dbinsertbp = Blueprint("dbinsert", __name__) @@ -91,7 +93,8 @@ def tissues() -> tuple: def select_platform(): "Select the platform (GeneChipId) used for the data." job_id = request.form["job_id"] - with Redis.from_url(app.config["REDIS_URL"], decode_responses=True) as rconn: + with (Redis.from_url(app.config["REDIS_URL"], decode_responses=True) as rconn, + database_connection(app.config["SQL_URI"]) as conn): job = jobs.job(rconn, job_id) if job: filename = job["filename"] @@ -102,7 +105,7 @@ def select_platform(): return render_template( "select_platform.html", filename=filename, filetype=job["filetype"], totallines=int(job["currentline"]), - default_species=default_species, species=species(), + default_species=default_species, species=species(conn), genechips=gchips[default_species], genechips_data=json.dumps(gchips)) return render_error(f"File '{filename}' no longer exists.") @@ -124,7 +127,10 @@ def select_study(): the_studies = studies_by_species_and_platform(speciesid, genechipid) the_groups = reduce( - organise_groups_by_family, groups_by_species(speciesid), {}) + organise_groups_by_family, + with_db_connection( + lambda conn: populations_by_species(conn, speciesid)), + {}) return render_template( "select_study.html", filename=form["filename"], filetype=form["filetype"], totallines=form["totallines"], |