forked from GithubBackups/healthchecks
Implementation of history using Flips model statuses for a check
This commit is contained in:
parent
aaadf6031f
commit
bc6ccd55b3
@ -237,16 +237,11 @@ class Check(models.Model):
|
|||||||
elif split[1] == 'w':
|
elif split[1] == 'w':
|
||||||
cutoff = current_now - td(weeks=int(split[0]))
|
cutoff = current_now - td(weeks=int(split[0]))
|
||||||
|
|
||||||
pings = Ping.objects.filter(owner=self, created__gte=cutoff).order_by("-id")#[:limit]
|
flips = Flip.objects.select_related("owner").filter(
|
||||||
pings = list(pings)
|
owner=self, new_status__in=("down","up"), created__gt=cutoff
|
||||||
|
).order_by("created")
|
||||||
alerts = Notification.objects.select_related("channel").filter(
|
dictStatus = {"up":1,"down":0}
|
||||||
owner=self, check_status="down", created__gt=cutoff
|
result['history'] = list(map(lambda x: {'timestamp':x.created,'status':dictStatus[x.new_status]}, flips))
|
||||||
)
|
|
||||||
|
|
||||||
events = pings + list(alerts)
|
|
||||||
events.sort(key=lambda el: el.created, reverse=True)
|
|
||||||
result['history'] = list(map(lambda x: {'timestamp':x.created,'status':x.kind}, events))
|
|
||||||
if readonly:
|
if readonly:
|
||||||
result["unique_key"] = self.unique_key
|
result["unique_key"] = self.unique_key
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user