Use Ping.kind instead of Ping.start and Ping.fail when displaying logs and ping details.

This commit is contained in:
Pēteris Caune 2019-01-04 12:07:27 +02:00
parent 7480eca2a5
commit 99d46a0ca8
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2
5 changed files with 9 additions and 9 deletions

View File

@ -18,7 +18,7 @@ class LastPingTestCase(BaseTestCase):
check = Check(user=self.alice) check = Check(user=self.alice)
check.save() check.save()
Ping.objects.create(owner=check, fail=True) Ping.objects.create(owner=check, kind="fail")
self.client.login(username="alice@example.org", password="password") self.client.login(username="alice@example.org", password="password")
r = self.client.get("/checks/%s/last_ping/" % check.code) r = self.client.get("/checks/%s/last_ping/" % check.code)
@ -28,7 +28,7 @@ class LastPingTestCase(BaseTestCase):
check = Check(user=self.alice) check = Check(user=self.alice)
check.save() check.save()
Ping.objects.create(owner=check, start=True) Ping.objects.create(owner=check, kind="start")
self.client.login(username="alice@example.org", password="password") self.client.login(username="alice@example.org", password="password")
r = self.client.get("/checks/%s/last_ping/" % check.code) r = self.client.get("/checks/%s/last_ping/" % check.code)

View File

@ -377,7 +377,7 @@ def _get_events(check, limit):
prev = None prev = None
for ping in pings: for ping in pings:
if ping.start and prev and not prev.start: if ping.kind == "start" and prev and prev.kind != "start":
delta = prev.created - ping.created delta = prev.created - ping.created
if delta < ONE_HOUR: if delta < ONE_HOUR:
setattr(prev, "delta", delta) setattr(prev, "delta", delta)

View File

@ -10,9 +10,9 @@
<td class="date"></td> <td class="date"></td>
<td class="time"></td> <td class="time"></td>
<td class="text-right"> <td class="text-right">
{% if event.fail %} {% if event.kind == "fail" %}
<span class="label label-danger">Failure</span> <span class="label label-danger">Failure</span>
{% elif event.start %} {% elif event.kind == "start" %}
<span class="label label-start">Started</span> <span class="label label-start">Started</span>
{% else %} {% else %}
<span class="label label-success">OK</span> <span class="label label-success">OK</span>

View File

@ -44,9 +44,9 @@
<td class="date"></td> <td class="date"></td>
<td class="time"></td> <td class="time"></td>
<td class="text-right"> <td class="text-right">
{% if event.fail %} {% if event.kind == "fail" %}
<span class="label label-danger">Failure</span> <span class="label label-danger">Failure</span>
{% elif event.start %} {% elif event.kind == "start" %}
<span class="label label-start">Started</span> <span class="label label-start">Started</span>
{% else %} {% else %}
<span class="label label-success">OK</span> <span class="label label-success">OK</span>

View File

@ -1,8 +1,8 @@
<div class="modal-body"> <div class="modal-body">
<h3>Ping #{{ ping.n }} <h3>Ping #{{ ping.n }}
{% if ping.fail %} {% if ping.kind == "fail" %}
<span class="text-danger">(received via the <code>/fail</code> endpoint)</span> <span class="text-danger">(received via the <code>/fail</code> endpoint)</span>
{% elif ping.start %} {% elif ping.kind == "start" %}
<span class="text-success">(received via the <code>/start</code> endpoint)</span> <span class="text-success">(received via the <code>/start</code> endpoint)</span>
{% endif %} {% endif %}
</h3> </h3>