Update notification checker (#3818)
# What this PR does Count sms with status "accepted" as delivered in notification checker ## Which issue(s) this PR fixes https://raintank-corp.slack.com/archives/C025VMT6SPK/p1706799009342889?thread_ts=1706786822.083149&cid=C025VMT6SPK ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required)
This commit is contained in:
parent
4e3194c106
commit
ba122ec6ef
2 changed files with 19 additions and 3 deletions
|
|
@ -112,7 +112,7 @@ def check_alert_group_personal_notifications_task(alert_group_id) -> None:
|
|||
# (ie. do not wait for Twilio delivered confirmation)
|
||||
sent_but_not_delivered_sms = SMSRecord.objects.filter(
|
||||
represents_alert_group_id=alert_group_id,
|
||||
twilioapp_twiliosmss__status=TwilioSMSstatuses.SENT,
|
||||
twilioapp_twiliosmss__status__in=[TwilioSMSstatuses.SENT, TwilioSMSstatuses.ACCEPTED],
|
||||
).count()
|
||||
|
||||
base_msg = f"Alert group {alert_group_id}"
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ def test_check_escalation_finished_task_calls_audit_alert_group_personal_notific
|
|||
# records created > 5 mins ago
|
||||
alert_group1.personal_log_records.update(created_at=now - timezone.timedelta(minutes=7))
|
||||
|
||||
# alert_group2: notify user, notification failed; triggered sms, sent status
|
||||
# alert_group2: notify user, notification failed; triggered 2 sms, sent and accepted statuses
|
||||
make_user_notification_policy_log_record(
|
||||
author=user,
|
||||
alert_group=alert_group2,
|
||||
|
|
@ -485,6 +485,13 @@ def test_check_escalation_finished_task_calls_audit_alert_group_personal_notific
|
|||
notification_step=UserNotificationPolicy.Step.NOTIFY,
|
||||
type=UserNotificationPolicyLogRecord.TYPE_PERSONAL_NOTIFICATION_TRIGGERED,
|
||||
)
|
||||
make_user_notification_policy_log_record(
|
||||
author=user,
|
||||
alert_group=alert_group2,
|
||||
notification_policy=user_notification_policy,
|
||||
notification_step=UserNotificationPolicy.Step.NOTIFY,
|
||||
type=UserNotificationPolicyLogRecord.TYPE_PERSONAL_NOTIFICATION_TRIGGERED,
|
||||
)
|
||||
# no failed or succeed record, but SMS was sent (without Twilio delivered confirmation yet)
|
||||
sms_record = make_sms_record(
|
||||
receiver=user,
|
||||
|
|
@ -492,10 +499,19 @@ def test_check_escalation_finished_task_calls_audit_alert_group_personal_notific
|
|||
notification_policy=user_notification_policy,
|
||||
)
|
||||
sent_sms = TwilioSMS.objects.create(sid="someid", sms_record=sms_record, status=TwilioSMSstatuses.SENT)
|
||||
# no failed or succeed record, but SMS has status ACCEPTED from Twilio (without Twilio delivered confirmation yet)
|
||||
sms_record2 = make_sms_record(
|
||||
receiver=user,
|
||||
represents_alert_group=alert_group2,
|
||||
notification_policy=user_notification_policy,
|
||||
)
|
||||
accepted_sms = TwilioSMS.objects.create(sid="someid2", sms_record=sms_record2, status=TwilioSMSstatuses.ACCEPTED)
|
||||
# records created > 5 mins ago
|
||||
alert_group2.personal_log_records.update(created_at=now - timezone.timedelta(minutes=7))
|
||||
sent_sms.created_at = now - timezone.timedelta(minutes=6)
|
||||
sent_sms.save()
|
||||
accepted_sms.created_at = now - timezone.timedelta(minutes=6)
|
||||
accepted_sms.save()
|
||||
|
||||
# alert_group3: notify user, missing completion
|
||||
make_user_notification_policy_log_record(
|
||||
|
|
@ -539,4 +555,4 @@ def test_check_escalation_finished_task_calls_audit_alert_group_personal_notific
|
|||
# also trigger the general personal notification checker
|
||||
check_personal_notifications_task()
|
||||
|
||||
assert "personal_notifications_triggered=5 personal_notifications_completed=2" in caplog.text
|
||||
assert "personal_notifications_triggered=6 personal_notifications_completed=2" in caplog.text
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue