From 0e5d578360b3f6eda0661d2f3f827d1d6fcd241a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Tue, 9 Jun 2020 18:41:09 +0300 Subject: [PATCH] Update _get_events to work same way as hc.api.views.pings (iterate over pings in ascending order) --- hc/front/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hc/front/views.py b/hc/front/views.py index db7b0121..3ed6e86b 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -478,11 +478,11 @@ def _get_events(check, limit): pings = list(pings) prev = None - for ping in pings: - if ping.kind == "start" and prev and prev.kind != "start": - delta = prev.created - ping.created + for ping in reversed(pings): + if ping.kind != "start" and prev and prev.kind == "start": + delta = ping.created - prev.created if delta < MAX_DELTA: - setattr(prev, "delta", delta) + setattr(ping, "delta", delta) prev = ping