aboutsummaryrefslogtreecommitdiff
path: root/qc_app/parse.py
diff options
context:
space:
mode:
Diffstat (limited to 'qc_app/parse.py')
-rw-r--r--qc_app/parse.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/qc_app/parse.py b/qc_app/parse.py
index ceb8fcf..40f7b44 100644
--- a/qc_app/parse.py
+++ b/qc_app/parse.py
@@ -7,7 +7,10 @@ from flask import flash, request, url_for, redirect, Blueprint, render_template
from flask import current_app as app
from quality_control.errors import InvalidValue, DuplicateHeading
-from . import jobs
+
+from qc_app import jobs
+from qc_app.dbinsert import species_by_id
+from qc_app.db_utils import with_db_connection
parsebp = Blueprint("parse", __name__)
@@ -23,8 +26,25 @@ def isduplicateheading(item):
def parse():
"""Trigger file parsing"""
errors = False
+ speciesid = request.args.get("speciesid")
filename = request.args.get("filename")
filetype = request.args.get("filetype")
+ if speciesid is None:
+ flash("No species selected", "alert-error")
+ errors = True
+ else:
+ try:
+ speciesid = int(speciesid)
+ species = with_db_connection(
+ lambda con: species_by_id(con, speciesid))
+ if not bool(species):
+ flash("No such species.", "alert-error")
+ errors = True
+ except ValueError:
+ flash("Invalid speciesid provided. Expected an integer.",
+ "alert-error")
+ errors = True
+
if filename is None:
flash("No file provided", "alert-error")
errors = True
@@ -50,7 +70,8 @@ def parse():
with Redis.from_url(redisurl, decode_responses=True) as rconn:
job = jobs.launch_job(
jobs.build_file_verification_job(
- rconn, filepath, filetype, redisurl,
+ rconn, app.config["SQL_URI"], redisurl,
+ speciesid, filepath, filetype,
app.config["JOBS_TTL_SECONDS"]),
redisurl,
f"{app.config['UPLOAD_FOLDER']}/job_errors")