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

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: Addressing comments 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
« no previous file with comments | « no previous file | appengine/findit/templates/try_job_dashboard.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e3a8ce563e73ebaf386dcfaa2aa099c617ffa398 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,20 @@ def _RemoveMicrosecondsFromDelta(delta):
return delta - timedelta(microseconds=delta.microseconds)
+def _FormatDuration(start_time, end_time):
+ return _FormatTimedelta(_GetTimeDelta(start_time, end_time))
+
+
+def _GetTimeDelta(start_time, end_time):
+ if not start_time or not end_time:
stgao 2016/06/03 06:36:04 Should this be moved to #24 above and get rid of #
lijeffrey 2016/06/03 19:40:47 Done.
+ return NOT_AVAILABLE
+ return end_time - start_time
+
+
def _FormatTimedelta(delta):
- if not delta:
- return None
+ if delta == NOT_AVAILABLE:
+ return NOT_AVAILABLE
+
hours, remainder = divmod(delta.seconds, 3600)
minutes, seconds = divmod(remainder, 60)
return '%02d:%02d:%02d' % (hours, minutes, seconds)
@@ -60,6 +74,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.start_time, reverse=True)
+
try_jobs_in_progress = []
try_jobs_with_error = []
successfully_completed_try_jobs = []
@@ -70,29 +88,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 | « no previous file | appengine/findit/templates/try_job_dashboard.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698