From 7d1f428348418991926b22ab454b269bd912fef6 Mon Sep 17 00:00:00 2001 From: sealion Date: Mon, 3 Mar 2014 16:47:15 +0400 Subject: [PATCH] Show end times in the report. --- app/cabotapp/views.py | 5 +++-- app/templates/cabotapp/statuscheck_report.html | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/cabotapp/views.py b/app/cabotapp/views.py index ab718b2..1b1b027 100644 --- a/app/cabotapp/views.py +++ b/app/cabotapp/views.py @@ -259,6 +259,7 @@ class StatusCheckReportForm(forms.Form): def get_report(self): checks = self.cleaned_data['checks'] + now = timezone.now() for check in checks: # Group results of the check by status (failed alternating with succeeded), # take time of the first one in each group (starting from a failed group), @@ -269,8 +270,8 @@ class StatusCheckReportForm(forms.Form): ).order_by('time') groups = dropwhile(lambda item: item[0], groupby(results, key=lambda r: r.succeeded)) times = [next(group).time for succeeded, group in groups] - pairs = izip_longest(*([iter(times)] * 2), fillvalue=timezone.now()) - check.problems = [(start, end - start) for start, end in pairs] + pairs = izip_longest(*([iter(times)] * 2)) + check.problems = [(start, end, (end or now) - start) for start, end in pairs] if results: check.success_rate = results.filter(succeeded=True).count() / float(len(results)) * 100 return checks diff --git a/app/templates/cabotapp/statuscheck_report.html b/app/templates/cabotapp/statuscheck_report.html index 468cda3..6279d4e 100644 --- a/app/templates/cabotapp/statuscheck_report.html +++ b/app/templates/cabotapp/statuscheck_report.html @@ -26,16 +26,20 @@ - + + - {% for start_time, duration in check.problems %} + {% for start_time, end_time, duration in check.problems %} +
TimeStart timeEnd time Duration
{{ start_time }} + {% if end_time %}{{ end_time }}{% else %}-{% endif %} + {{ duration|format_timedelta }}