diff options
| author | Frederick Muriuki Muriithi | 2026-01-08 09:29:18 -0600 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2026-01-08 09:29:18 -0600 |
| commit | 05687ca762e8ed2a6b551ec9202f396a11f9008a (patch) | |
| tree | c682c2f83efe5c004c3466b1db16da1675fa1845 | |
| parent | fa72bd33e3eee9e7d1b425967c84ccc4a1d0200a (diff) | |
| download | gn-uploader-05687ca762e8ed2a6b551ec9202f396a11f9008a.tar.gz | |
View a job's details/summary.
| -rw-r--r-- | uploader/background_jobs.py | 16 | ||||
| -rw-r--r-- | uploader/templates/background-jobs/job-summary.html | 62 |
2 files changed, 78 insertions, 0 deletions
diff --git a/uploader/background_jobs.py b/uploader/background_jobs.py index da3c8ed..64d55e9 100644 --- a/uploader/background_jobs.py +++ b/uploader/background_jobs.py @@ -141,3 +141,19 @@ def list_jobs(): conn, session.user_details()["user_id"]), display_datetime=lambda val: datetime.datetime.fromisoformat( val).strftime("%A, %d %B %Y at %H:%M %Z")) + + +@background_jobs_bp.route("/summary/<uuid:job_id>") +@require_login +def job_summary(job_id: uuid.UUID): + """Provide a summary for completed jobs.""" + with sqlite3.connection(app.config["ASYNCHRONOUS_JOBS_SQLITE_DB"]) as conn: + try: + job = jobs.job(conn, job_id, fulldetails=True) + status = job["metadata"]["status"] + + if status in ("completed", "error"): + return render_template("background-jobs/job-summary.html", job=job) + return redirect(url_for("background-jobs.job_status", job["job_id"])) + except JobNotFound as _jnf: + return render_template("jobs/job-not-found.html", job_id=job_id) diff --git a/uploader/templates/background-jobs/job-summary.html b/uploader/templates/background-jobs/job-summary.html new file mode 100644 index 0000000..fef89f2 --- /dev/null +++ b/uploader/templates/background-jobs/job-summary.html @@ -0,0 +1,62 @@ +{%extends "background-jobs/base.html"%} +{%from "flash_messages.html" import flash_all_messages%} + +{%block title%}Background Jobs{%endblock%} + +{%block pagetitle%}Background Jobs{%endblock%} + +{%block breadcrumbs%} +{{super()}} +<li class="breadcrumb-item"> + <a href="{{url_for('background-jobs.job_summary', job_id=job.job_id)}}"> + summary + </a> +</li> +{%endblock%} + +{%block contents%} +{{flash_all_messages()}} + +<div class="row"> + <h2 class="heading">background jobs: summary</h2> + + <table class="table"> + <thead> + <tr class="table-primary"> + <th>Job ID</th> + <th>Type</th> + <th>Status</th> + </tr> + </thead> + + <tbody> + <tr> + <td>{{job.job_id}}</td> + <td>{{job.metadata["job-type"]}}</td> + <td>{{job.metadata.status}}</td> + </tr> + </tbody> + </table> +</div> + +<div class="row"> + <h3 class="subheading">Script Errors and Logging</h3> + <pre>{{job["stderr"]}}</pre> +</div> + +<div class="row"> + <h3 class="subheading">Script Output</h3> + <pre>{{job["stdout"]}}</pre> +</div> +{%endblock%} + + +{%block sidebarcontents%} +<div class="row"> + <h6 class="subheading">What is this?</h6> +</div> +<div class="row"> + <p>This page shows the results of running job '{{job.job_id}}'.</p> +</div> +{{super()}} +{%endblock%} |
