From c59e23efda9879337080fa346e218f1a5d8233ae Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Thu, 16 Sep 2021 19:20:43 +1000 Subject: [PATCH] provide estimates, format dates better --- job.py | 8 +++++++- templates/joblog.html | 6 +++++- templates/jobs.html | 6 +++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/job.py b/job.py index 4c2ae71..c29667e 100644 --- a/job.py +++ b/job.py @@ -134,7 +134,13 @@ def joblog(id): else: duration=(datetime.now(pytz.utc)-joblog.start_time) duration= duration-timedelta(microseconds=duration.microseconds) - return render_template("joblog.html", job=joblog, logs=logs, log_cnt=log_cnt, duration=duration, page_title=page_title, first_logs_only=first_logs_only) + estimate=None + duration_s = duration.total_seconds() + if duration_s > 300 and joblog.pa_job_state != "Completed": + estimate_s = duration_s / joblog.current_file_num * joblog.num_files + estimate = timedelta( seconds=(estimate_s-duration_s) ) + estimate = estimate - timedelta(microseconds=estimate.microseconds) + return render_template("joblog.html", job=joblog, logs=logs, log_cnt=log_cnt, duration=duration, page_title=page_title, first_logs_only=first_logs_only, estimate=estimate) ############################################################################### # /job/ -> GET -> shows status/history of jobs diff --git a/templates/joblog.html b/templates/joblog.html index 60a4e9f..5dd0c83 100644 --- a/templates/joblog.html +++ b/templates/joblog.html @@ -11,7 +11,11 @@
Start Time:
{{job.start_time|vicdate}}
Duration:
-
{{duration}}
+
{{duration}} + {% if estimate != None %} + (estimated time remaining: {{estimate}}) + {% endif %} +
Last Update:
{{job.last_update|vicdate}}
Current state:
diff --git a/templates/jobs.html b/templates/jobs.html index ec05c0d..63b2507 100644 --- a/templates/jobs.html +++ b/templates/jobs.html @@ -23,9 +23,9 @@ {% endif %} {% if job.state == "Withdrawn" %} - row+= '{{job.start_time}}' + row+= '{{job.start_time|vicdate}}' {% else %} - row+= '{{job.start_time}}' + row+= '{{job.start_time|vicdate}}' {% endif %} {% if job.pa_job_state != "Completed" %} {% if job.num_files and job.num_files > 0 %} @@ -43,7 +43,7 @@ {% endif %} active_rows.push(row) {% else %} - row += '{{job.last_update}}' + row += '{{job.last_update|vicdate}}' completed_rows.push(row) {% endif %} {% endfor %}