aboutsummaryrefslogtreecommitdiff
path: root/qc_app/dbinsert.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-07-13 02:37:52 +0300
committerFrederick Muriuki Muriithi2022-07-19 04:59:59 +0300
commit68cf0750ee29d91abf8fe8d0a81426e324b41b12 (patch)
treeed1b752cb63937ebe5d1c5cca812cbd0f7bd65a6 /qc_app/dbinsert.py
parent27032e1876373f9b519275bffbca117f2c96ca1f (diff)
downloadgn-uploader-68cf0750ee29d91abf8fe8d0a81426e324b41b12.tar.gz
Implement dataset selection
- Implement UI enabling selection from existing datasets - Start implementation of UI that enables creation of new dataset
Diffstat (limited to 'qc_app/dbinsert.py')
-rw-r--r--qc_app/dbinsert.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/qc_app/dbinsert.py b/qc_app/dbinsert.py
index 4fbd0d3..523152d 100644
--- a/qc_app/dbinsert.py
+++ b/qc_app/dbinsert.py
@@ -177,6 +177,17 @@ def create_study():
flash(f"Missing data: {aserr.args[0]}", "alert-error")
return redirect(url_for("dbinsert.select_study"), code=307)
+def datasets_by_study(studyid:int) -> tuple:
+ "Retrieve datasets associated with a study with the ID `studyid`."
+ with database_connection() as conn:
+ with conn.cursor(cursorclass=DictCursor) as cursor:
+ query = "SELECT * FROM ProbeSetFreeze WHERE ProbeFreezeId=%s"
+ print(f"QUERY: {query}\n\tPARAMS: ({studyid},)")
+ cursor.execute(query, (studyid,))
+ return tuple(cursor.fetchall())
+
+ return tuple()
+
@dbinsertbp.route("/dataset", methods=["POST"])
def select_dataset():
"Select the dataset to add the file contents against"
@@ -186,15 +197,14 @@ def select_dataset():
assert form.get("filetype"), "filetype"
assert form.get("species"), "species"
assert form.get("genechipid"), "platform"
- assert (form.get("studyid") or form.get(studyname)), ""
- assert form.get(""), ""
- assert form.get(""), ""
- assert form.get(""), ""
- assert form.get(""), ""
+ assert (form.get("studyid") or request.args.get("studyid")), "study"
+ studyid=(form.get("studyid") or request.args.get("studyid"))
+ datasets = datasets_by_study(studyid)
return render_template(
"select_dataset.html", filename=form["filename"],
- filetype=form["filetype"], species=speciesid, genechipid=genechipid)
+ filetype=form["filetype"], species=form["species"],
+ genechipid=form["genechipid"], studyid=studyid, datasets=datasets)
except AssertionError as aserr:
return render_error(f"Missing data: {aserr.args[0]}")