From b9ae8d464cf1f38435905e4728af682f586e354d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Sat, 2 Jan 2016 22:27:25 +0200 Subject: [PATCH] Sort by id, not `created`, when pruning pings. --- hc/api/models.py | 2 +- hc/api/tests/test_check_model.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hc/api/models.py b/hc/api/models.py index 8735b87f..5191508a 100644 --- a/hc/api/models.py +++ b/hc/api/models.py @@ -104,7 +104,7 @@ class Check(models.Model): """ - pings = Ping.objects.filter(owner=self).order_by("-created") + pings = Ping.objects.filter(owner=self).order_by("-id") cutoff = pings[keep_limit:keep_limit+1] # If cutoff is empty slice then the check has less than `keep_limit` diff --git a/hc/api/tests/test_check_model.py b/hc/api/tests/test_check_model.py index 0c559a7d..2d37ed29 100644 --- a/hc/api/tests/test_check_model.py +++ b/hc/api/tests/test_check_model.py @@ -9,7 +9,7 @@ class CheckModelTestCase(TestCase): check.save() for i in range(0, 6): - p = Ping(pk=100 + i, owner=check, ua="UA%d" % i) + p = Ping(owner=check, ua="UA%d" % i) p.save() check.prune_pings(keep_limit=3)