0
0
Fork 0
mirror of https://github.com/healthchecks/healthchecks.git synced 2025-04-08 06:30:05 +00:00

Fix off-by-one-month error in monthly reports, downtime columns

Fixes: 
This commit is contained in:
Pēteris Caune 2021-07-02 15:22:51 +03:00
parent 61a8a8de26
commit d243f502d3
No known key found for this signature in database
GPG key ID: E28D7679E9A9EDE2
4 changed files with 11 additions and 4 deletions

View file

@ -12,6 +12,9 @@ All notable changes to this project will be documented in this file.
- Implement PagerDuty Simple Install Flow, remove PD Connect
- Implement dark mode
### Bug Fixes
- Fix off-by-one-month error in monthly reports, downtime columns (#539)
## v1.20.0 - 2020-04-22
### Improvements

View file

@ -307,7 +307,7 @@ class Check(models.Model):
ping.exitstatus = exitstatus
ping.save()
def downtimes(self, months=2):
def downtimes(self, months):
""" Calculate the number of downtimes and downtime minutes per month.
Returns a list of (datetime, downtime_in_secs, number_of_outages) tuples.
@ -351,6 +351,11 @@ class Check(models.Model):
return sorted(totals.values())
def past_downtimes(self):
""" Return downtime summary for two previous months. """
return self.downtimes(3)[:-1]
class Ping(models.Model):
id = models.BigAutoField(primary_key=True)

View file

@ -1,5 +1,4 @@
from datetime import datetime as dt
from random import randint
from django.utils import timezone
@ -71,7 +70,7 @@ def format_approx_duration(td):
return ""
def month_boundaries(months=2):
def month_boundaries(months):
result = []
now = timezone.now()

View file

@ -60,7 +60,7 @@
</table>
{% endif %}
</td>
{% for boundary, seconds, count in check.downtimes %}
{% for boundary, seconds, count in check.past_downtimes %}
{% if count %}
<td style="border-top: 1px solid #EDEFF2; padding: 16px 8px; font-family: Helvetica, Arial, sans-serif;">
{{ count }}&nbsp;downtime{{ count|pluralize }},