From d0eefc60e7864060bdbc1617fedf8c1697f797d9 Mon Sep 17 00:00:00 2001 From: Frank Hamand Date: Thu, 4 May 2017 17:37:04 +0100 Subject: [PATCH] Make alert test correctly show "ALERT_TEST" as the failing check --- cabot/cabotapp/views.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cabot/cabotapp/views.py b/cabot/cabotapp/views.py index df22d1c14..1a3a204aa 100644 --- a/cabot/cabotapp/views.py +++ b/cabot/cabotapp/views.py @@ -702,11 +702,19 @@ def trigger_alert_to_user(self, service, user, old_status, new_status): with transaction.atomic(): sid = transaction.savepoint() service.update_status() + service.status_checks.update(active=False) service.overall_status = new_status service.old_overall_status = old_status service.last_alert_sent = None - check = StatusCheck(name='ALERT_TEST', calculated_status=service.overall_status) + check = StatusCheck(name='ALERT_TEST') + check.save() + StatusCheckResult.objects.create( + status_check=check, + time=timezone.now(), + time_complete=timezone.now(), + succeeded=new_status == Service.PASSING_STATUS) + check.last_run = timezone.now() check.save() service.status_checks.add(check) service.users_to_notify.clear()