Browse Source

Overwrite Check.last_start value

pull/211/head
Pēteris Caune 6 years ago
parent
commit
eee6fc12f4
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
2 changed files with 1 additions and 17 deletions
  1. +1
    -4
      hc/api/models.py
  2. +0
    -13
      hc/api/tests/test_ping.py

+ 1
- 4
hc/api/models.py View File

@ -219,10 +219,7 @@ class Check(models.Model):
def ping(self, remote_addr, scheme, method, ua, body, action): def ping(self, remote_addr, scheme, method, ua, body, action):
if action == "start": if action == "start":
# If we receive multiple start events in a row,
# we remember the first one, not the last one
if self.last_start is None:
self.last_start = timezone.now()
self.last_start = timezone.now()
# DOn't update "last_ping" field. # DOn't update "last_ping" field.
else: else:
self.last_start = None self.last_start = None


+ 0
- 13
hc/api/tests/test_ping.py View File

@ -168,16 +168,3 @@ class PingTestCase(TestCase):
self.check.refresh_from_db() self.check.refresh_from_db()
self.assertTrue(self.check.last_start) self.assertTrue(self.check.last_start)
self.assertEqual(self.check.status, "paused") self.assertEqual(self.check.status, "paused")
def test_start_does_not_overwrite_last_start(self):
first_start = now() - td(hours=2)
self.check.last_start = first_start
self.check.save()
r = self.client.get("/ping/%s/start" % self.check.code)
self.assertEqual(r.status_code, 200)
self.check.refresh_from_db()
# Should still be the original value
self.assertEqual(self.check.last_start, first_start)

Loading…
Cancel
Save