From f35f66a6eaa6af0e101cbd6ec4bb1a8ba9c0bccf Mon Sep 17 00:00:00 2001 From: Yulya Artyukhina Date: Thu, 10 Oct 2024 17:37:30 +0200 Subject: [PATCH] Fix retrying tasks (#5160) # What this PR does Small fixes for some retrying tasks ## Which issue(s) this PR closes https://github.com/grafana/oncall-private/issues/2965 https://github.com/grafana/oncall-private/issues/2964 ## Checklist - [ ] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] Added the relevant release notes label (see labels prefixed w/ `release:`). These labels dictate how your PR will show up in the autogenerated release notes. --- engine/apps/alerts/models/alert_receive_channel.py | 2 ++ engine/apps/alerts/tasks/notify_user.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/engine/apps/alerts/models/alert_receive_channel.py b/engine/apps/alerts/models/alert_receive_channel.py index 2c45c68d..100b5b7b 100644 --- a/engine/apps/alerts/models/alert_receive_channel.py +++ b/engine/apps/alerts/models/alert_receive_channel.py @@ -422,6 +422,8 @@ class AlertReceiveChannel(IntegrationOptionsMixin, MaintainableObject): @property def new_incidents_web_link(self): + from apps.alerts.models import AlertGroup + return UIURLBuilder(self.organization).alert_groups( f"?integration={self.public_primary_key}&status={AlertGroup.NEW}", ) diff --git a/engine/apps/alerts/tasks/notify_user.py b/engine/apps/alerts/tasks/notify_user.py index 53b88129..7ad2bb49 100644 --- a/engine/apps/alerts/tasks/notify_user.py +++ b/engine/apps/alerts/tasks/notify_user.py @@ -400,7 +400,7 @@ def perform_notification(log_record_pk, use_default_notification_policy_fallback UserNotificationPolicyLogRecord( author=user, type=UserNotificationPolicyLogRecord.TYPE_PERSONAL_NOTIFICATION_FAILED, - notification_policy=notification_policy, + notification_policy=notification_policy if not use_default_notification_policy_fallback else None, reason="Expected data is missing", alert_group=alert_group, notification_step=notification_policy.step if notification_policy else None, @@ -424,7 +424,7 @@ def perform_notification(log_record_pk, use_default_notification_policy_fallback UserNotificationPolicyLogRecord( author=user, type=UserNotificationPolicyLogRecord.TYPE_PERSONAL_NOTIFICATION_FAILED, - notification_policy=notification_policy, + notification_policy=notification_policy if not use_default_notification_policy_fallback else None, reason="Skipped notification because alert group is resolved", alert_group=alert_group, notification_step=notification_policy.step if notification_policy else None,