From 971d1383aa81947a1d43725150bcfa6eceec24f0 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 13 Feb 2024 04:09:34 +0300 Subject: Provide nice UI progress indicators. --- qc_app/templates/rqtl2/rqtl2-qc-job-status.html | 31 ++++++++++++++++++------- qc_app/upload/rqtl2.py | 22 +++++++++++++++--- 2 files changed, 42 insertions(+), 11 deletions(-) (limited to 'qc_app') diff --git a/qc_app/templates/rqtl2/rqtl2-qc-job-status.html b/qc_app/templates/rqtl2/rqtl2-qc-job-status.html index 85b8864..4bdc983 100644 --- a/qc_app/templates/rqtl2/rqtl2-qc-job-status.html +++ b/qc_app/templates/rqtl2/rqtl2-qc-job-status.html @@ -10,14 +10,29 @@ {%block contents%}

R/qtl2 bundle: QC job status

-

R/qtl2 bundle: QC Job Status

- -
-

The job:

-
-{{job}} -
-
+{%if geno_percent%} +

+

Checking 'geno' file:

+ + {{geno_percent}}% + {{geno_percent}}%

+{%endif%} + +{%if pheno_percent%} +

+

Checking 'pheno' file:

+ + {{pheno_percent}}% + {{pheno_percent}}%

+{%endif%} + +{%if phenose_percent%} +

+

Checking 'phenose' file:

+ + {{phenose_percent}}% + {{phenose_percent}}%

+{%endif%}

Log

diff --git a/qc_app/upload/rqtl2.py b/qc_app/upload/rqtl2.py index 66b219d..a32019f 100644 --- a/qc_app/upload/rqtl2.py +++ b/qc_app/upload/rqtl2.py @@ -1,6 +1,7 @@ """Module to handle uploading of R/qtl2 bundles.""" import sys import json +from typing import Union from pathlib import Path from datetime import date from uuid import UUID, uuid4 @@ -227,9 +228,24 @@ def rqtl2_bundle_qc_status(jobid: UUID): rqtl2bundle=Path(jobmeta["rqtl2-bundle-file"]), rqtl2bundleorig=jobmeta["original-filename"]) - return render_template("rqtl2/rqtl2-qc-job-status.html", - job=thejob, - messages=tuple()) + def compute_percentage(thejob, filetype) -> Union[str, None]: + if f"{filetype}-linecount" in thejob: + return "100" + if f"{filetype}-filesize" in thejob: + percent = ((int(thejob.get(f"{filetype}-checked", 0)) + / + int(thejob.get(f"{filetype}-filesize", 1))) + * 100) + return f"{percent:.2f}" + return None + + return render_template( + "rqtl2/rqtl2-qc-job-status.html", + job=thejob, + geno_percent=compute_percentage(thejob, "geno"), + pheno_percent=compute_percentage(thejob, "pheno"), + phenose_percent=compute_percentage(thejob, "phenose"), + messages=tuple()) except jobs.JobNotFound: return render_template("rqtl2/no-such-job.html", jobid=jobid) -- cgit v1.2.3