From 9cbd3bfc5a5cfe35cb6f0b4cf711e385bfecd77a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Wed, 6 Nov 2019 10:41:14 +0200 Subject: [PATCH] In monthly reports, no downtime stats for the current month (month has just started) --- CHANGELOG.md | 4 +++- hc/api/models.py | 2 +- hc/lib/date.py | 2 +- templates/emails/summary-downtimes-html.html | 4 ++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13aa5a81..36e565f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,10 @@ All notable changes to this project will be documented in this file. ## Unreleased -### Bug Fixes +### Improvements +- In monthly reports, no downtime stats for the current month (month has just started) +### Bug Fixes - On mobile, "My Checks" page, always show the gear (Details) button (#286) - Make log events fit better on mobile screens diff --git a/hc/api/models.py b/hc/api/models.py index fb8272d4..9f19b854 100644 --- a/hc/api/models.py +++ b/hc/api/models.py @@ -273,7 +273,7 @@ class Check(models.Model): ping.body = body[:10000] ping.save() - def downtimes(self, months=2): + def downtimes(self, months=3): """ Calculate the number of downtimes and downtime minutes per month. Returns a list of (datetime, downtime_in_secs, number_of_outages) tuples. diff --git a/hc/lib/date.py b/hc/lib/date.py index 8cd1ae7a..6f445dc3 100644 --- a/hc/lib/date.py +++ b/hc/lib/date.py @@ -68,7 +68,7 @@ def format_approx_duration(td): return "" -def month_boundaries(months=2): +def month_boundaries(months=3): result = [] now = timezone.now() diff --git a/templates/emails/summary-downtimes-html.html b/templates/emails/summary-downtimes-html.html index c653fd16..bda9b3e6 100644 --- a/templates/emails/summary-downtimes-html.html +++ b/templates/emails/summary-downtimes-html.html @@ -7,9 +7,11 @@ {{ group.grouper|mangle_link }} {% for dt in month_boundaries %} + {% if not forloop.last %} {{ dt|date:"N Y"}} + {% endif %} {% endfor %} {% for check in group.list|sortchecks:sort %} @@ -63,6 +65,7 @@ {% endif %} {% for boundary, seconds, count in check.downtimes %} + {% if not forloop.last %} {% if count %} {{ count }} downtime{{ count|pluralize }}, @@ -74,6 +77,7 @@ All good! {% endif %} + {% endif %} {% endfor %} {% endfor %}