Chromium Code Reviews| 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..84f976c9ef96fb25e7db08605e9c723ff755a039 100644 |
| --- a/appengine/findit/handlers/try_job_dashboard.py |
| +++ b/appengine/findit/handlers/try_job_dashboard.py |
| @@ -17,9 +17,17 @@ 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: |
| + return timedelta(0) |
|
stgao
2016/06/02 22:13:57
Should we do "N/A" instead if any time is None?
lijeffrey
2016/06/03 03:18:27
Done.
|
| + return 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) |
| @@ -77,7 +85,7 @@ class TryJobDashboard(BaseHandler): |
| 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'] = ( |
| @@ -86,13 +94,17 @@ class TryJobDashboard(BaseHandler): |
| 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_job_display_data['in_queue_time'] = _FormatDuration( |
|
stgao
2016/06/02 22:13:57
nit: "pending time"? Same for UI.
lijeffrey
2016/06/03 03:18:27
Done.
|
| + try_job_data.request_time, try_job_data.start_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) |
| + try_job_display_data['in_queue_time'] = _FormatDuration( |
| + try_job_data.request_time, try_job_data.start_time) |
| successfully_completed_try_jobs.append(try_job_display_data) |
| data = { |