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: #539
This commit is contained in:
parent
61a8a8de26
commit
d243f502d3
4 changed files with 11 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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 }} downtime{{ count|pluralize }},
|
||||
|
|
Loading…
Add table
Reference in a new issue