forked from GithubBackups/healthchecks
Fix off-by-one-month error in monthly reports, downtime columns
Fixes: #539
This commit is contained in:
parent
61a8a8de26
commit
d243f502d3
@ -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 PagerDuty Simple Install Flow, remove PD Connect
|
||||||
- Implement dark mode
|
- Implement dark mode
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
- Fix off-by-one-month error in monthly reports, downtime columns (#539)
|
||||||
|
|
||||||
## v1.20.0 - 2020-04-22
|
## v1.20.0 - 2020-04-22
|
||||||
|
|
||||||
### Improvements
|
### Improvements
|
||||||
|
@ -307,7 +307,7 @@ class Check(models.Model):
|
|||||||
ping.exitstatus = exitstatus
|
ping.exitstatus = exitstatus
|
||||||
ping.save()
|
ping.save()
|
||||||
|
|
||||||
def downtimes(self, months=2):
|
def downtimes(self, months):
|
||||||
""" Calculate the number of downtimes and downtime minutes per month.
|
""" Calculate the number of downtimes and downtime minutes per month.
|
||||||
|
|
||||||
Returns a list of (datetime, downtime_in_secs, number_of_outages) tuples.
|
Returns a list of (datetime, downtime_in_secs, number_of_outages) tuples.
|
||||||
@ -351,6 +351,11 @@ class Check(models.Model):
|
|||||||
|
|
||||||
return sorted(totals.values())
|
return sorted(totals.values())
|
||||||
|
|
||||||
|
def past_downtimes(self):
|
||||||
|
""" Return downtime summary for two previous months. """
|
||||||
|
|
||||||
|
return self.downtimes(3)[:-1]
|
||||||
|
|
||||||
|
|
||||||
class Ping(models.Model):
|
class Ping(models.Model):
|
||||||
id = models.BigAutoField(primary_key=True)
|
id = models.BigAutoField(primary_key=True)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from datetime import datetime as dt
|
from datetime import datetime as dt
|
||||||
from random import randint
|
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
|
|
||||||
@ -71,7 +70,7 @@ def format_approx_duration(td):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
def month_boundaries(months=2):
|
def month_boundaries(months):
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
now = timezone.now()
|
now = timezone.now()
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
</table>
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
{% for boundary, seconds, count in check.downtimes %}
|
{% for boundary, seconds, count in check.past_downtimes %}
|
||||||
{% if count %}
|
{% if count %}
|
||||||
<td style="border-top: 1px solid #EDEFF2; padding: 16px 8px; font-family: Helvetica, Arial, sans-serif;">
|
<td style="border-top: 1px solid #EDEFF2; padding: 16px 8px; font-family: Helvetica, Arial, sans-serif;">
|
||||||
{{ count }} downtime{{ count|pluralize }},
|
{{ count }} downtime{{ count|pluralize }},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user