Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1440)

Unified Diff: appengine/findit/handlers/try_job_dashboard.py

Issue 2035793004: [Findit] Updating try job dashboard to display in queue and execution times (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fixing unit tests Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/findit/handlers/try_job_dashboard.py
diff --git a/appengine/findit/handlers/try_job_dashboard.py b/appengine/findit/handlers/try_job_dashboard.py
index cc1589daa662a7bd8f65014185d7e5109207b60c..56f1ea3a5e593d01a26be759ef6202049fffec9c 100644
--- a/appengine/findit/handlers/try_job_dashboard.py
+++ b/appengine/findit/handlers/try_job_dashboard.py
@@ -10,6 +10,9 @@ from common.base_handler import Permission
from model.wf_try_job_data import WfTryJobData
+NOT_AVAILABLE = 'N/A'
+
+
# TODO(lijeffrey): Refactor formatting functions into a separate module that
# can be shared across Findit.
def _RemoveMicrosecondsFromDelta(delta):
@@ -17,9 +20,13 @@ def _RemoveMicrosecondsFromDelta(delta):
return delta - timedelta(microseconds=delta.microseconds)
+def _FormatDuration(start_time, end_time):
+ if not start_time or not end_time:
+ return NOT_AVAILABLE
+ return _FormatTimedelta(end_time - start_time)
+
+
def _FormatTimedelta(delta):
- if not delta:
- return None
hours, remainder = divmod(delta.seconds, 3600)
minutes, seconds = divmod(remainder, 60)
return '%02d:%02d:%02d' % (hours, minutes, seconds)
@@ -60,6 +67,10 @@ class TryJobDashboard(BaseHandler):
WfTryJobData.request_time < end_date)
try_job_data_list = try_job_query.fetch()
+
+ # Sort try job data list by most recent request first.
+ try_job_data_list.sort(key=lambda x: x.request_time, reverse=True)
+
try_jobs_in_progress = []
try_jobs_with_error = []
successfully_completed_try_jobs = []
@@ -70,29 +81,29 @@ class TryJobDashboard(BaseHandler):
'builder_name': try_job_data.builder_name,
'build_number': try_job_data.build_number,
'try_job_type': try_job_data.try_job_type,
- 'start_time': _FormatDatetime(try_job_data.start_time),
+ 'pending_time': _FormatDuration(
+ try_job_data.request_time, try_job_data.start_time),
'request_time': _FormatDatetime(try_job_data.request_time),
'try_job_url': try_job_data.try_job_url
}
if not try_job_data.end_time and not try_job_data.error:
try_job_display_data['elapsed_time'] = (
- _FormatTimedelta(datetime.utcnow() - try_job_data.request_time) if
+ _FormatDuration(try_job_data.request_time, datetime.utcnow()) if
try_job_data.request_time else None)
-
try_job_display_data['status'] = (
'running' if try_job_data.start_time else 'pending')
try_jobs_in_progress.append(try_job_display_data)
elif try_job_data.error:
try_job_display_data['error'] = try_job_data.error['message']
# It is possible end_time is not available if the error was timeout.
- try_job_display_data['end_time'] = _FormatDatetime(
- try_job_data.end_time)
+ try_job_display_data['execution_time'] = _FormatDuration(
+ try_job_data.start_time, try_job_data.end_time)
try_jobs_with_error.append(try_job_display_data)
else:
try_job_display_data['culprit_found'] = bool(try_job_data.culprits)
- try_job_display_data['end_time'] = (
- _FormatDatetime(try_job_data.end_time))
+ try_job_display_data['execution_time'] = _FormatDuration(
+ try_job_data.start_time, try_job_data.end_time)
successfully_completed_try_jobs.append(try_job_display_data)
data = {
« no previous file with comments | « appengine/findit/handlers/test/try_job_dashboard_test.py ('k') | appengine/findit/templates/try_job_dashboard.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698