Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User notifications bundle #4457

Merged
merged 32 commits into from
Jul 16, 2024
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0dcad9f
Update user has notification
Ferril Jun 4, 2024
872990c
Add user notification bundle model
Ferril Jun 4, 2024
2ab8315
Add bundling for user notifications
Ferril Jun 4, 2024
63bc4d0
Fix update metrics
Ferril Jun 4, 2024
7e889fe
Update sending and tracking bundled notifications
Ferril Jun 7, 2024
59a9664
remove commented code
Ferril Jun 7, 2024
94c66ee
Update comment
Ferril Jun 7, 2024
271c99f
Fix updating metrics on user notification
Ferril Jun 10, 2024
ea06498
Fix updating metrics on user notification
Ferril Jun 13, 2024
cb71560
Update user notification bundle
Ferril Jun 18, 2024
b0db509
Add test for updating metrics for bundled notifications
Ferril Jun 18, 2024
c943841
Add tests for bundling notifications
Ferril Jun 18, 2024
0b036e6
Add test for notification bundle
Ferril Jun 18, 2024
1145755
Update send_bundled_notification task
Ferril Jun 19, 2024
4ff84fe
update test
Ferril Jun 19, 2024
59d9d65
Update UserNotificationBundle
Ferril Jun 20, 2024
5d34609
Rename some functions, add comments
Ferril Jun 20, 2024
a44af00
Add `alert_receive_channel` field to `BundledNotification`
Ferril Jul 3, 2024
ef3eecc
Update notification bundle
Ferril Jul 3, 2024
5fc5d5e
Fix notification bundle
Ferril Jul 3, 2024
834f8a2
Fix test
Ferril Jul 3, 2024
0b8a91e
fix sending signal for notification bundle
Ferril Jul 4, 2024
95bb29d
Merge branch 'dev' into user-notification-bundle
Ferril Jul 8, 2024
e85776b
Merge branch 'dev' into user-notification-bundle
Ferril Jul 8, 2024
e0e237d
remove comment
Ferril Jul 8, 2024
e2f2727
Update typing
Ferril Jul 9, 2024
cc1ede0
remove todo comment
Ferril Jul 9, 2024
d6b9242
Merge branch 'dev' into user-notification-bundle
Ferril Jul 10, 2024
0394ea1
Fix notify_user_task
Ferril Jul 10, 2024
4eed7d8
Fix mypy
Ferril Jul 11, 2024
58cf5ef
Merge branch 'dev' into user-notification-bundle
Ferril Jul 16, 2024
1431674
Fix migration
Ferril Jul 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'dev' into user-notification-bundle
# Conflicts:
#	engine/apps/alerts/tasks/notify_user.py
#	engine/settings/base.py
Ferril committed Jul 8, 2024
commit 95bb29d592e0de764830ae9feb278675adfd6026
15 changes: 7 additions & 8 deletions engine/apps/alerts/tasks/notify_user.py
Original file line number Diff line number Diff line change
@@ -41,17 +41,16 @@ def schedule_perform_notification_task(log_record_pk, alert_group_pk):
)


def build_notification_reason_for_log_record(notification_policy, reason):
def build_notification_reason_for_log_record(notification_policies, reason):
Ferril marked this conversation as resolved.
Show resolved Hide resolved
from apps.base.models import UserNotificationPolicy

# Here we collect a brief overview of notification steps configured for user to send it to thread.
collected_steps_ids = []
next_notification_policy = notification_policy.next()
while next_notification_policy is not None:
if next_notification_policy.step == UserNotificationPolicy.Step.NOTIFY:
if next_notification_policy.notify_by not in collected_steps_ids:
collected_steps_ids.append(next_notification_policy.notify_by)
next_notification_policy = next_notification_policy.next()
for notification_policy in notification_policies:
if notification_policy.step == UserNotificationPolicy.Step.NOTIFY:
if notification_policy.notify_by not in collected_steps_ids:
collected_steps_ids.append(notification_policy.notify_by)

collected_steps = ", ".join(
UserNotificationPolicy.NotificationChannel(step_id).label for step_id in collected_steps_ids
)
@@ -138,7 +137,7 @@ def notify_user_task(
f"notify_user_task: Failed to notify. No notification policies. user_id={user_pk} alert_group_id={alert_group_pk} important={important}"
)
return
reason = build_notification_reason_for_log_record(notification_policy, reason)
reason = build_notification_reason_for_log_record(notification_policies, reason)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! slowly breaks apart this function 🙂

else:
if notify_user_task.request.id != user_has_notification.active_notification_policy_id:
task_logger.info(
1 change: 1 addition & 0 deletions engine/settings/base.py
Original file line number Diff line number Diff line change
@@ -71,6 +71,7 @@
FEATURE_LABELS_ENABLED_FOR_ALL = getenv_boolean("FEATURE_LABELS_ENABLED_FOR_ALL", default=False)
# Enable labels feature for organizations from the list. Use OnCall organization ID, for this flag
FEATURE_LABELS_ENABLED_PER_ORG = getenv_list("FEATURE_LABELS_ENABLED_PER_ORG", default=list())
FEATURE_ALERT_GROUP_SEARCH_ENABLED = getenv_boolean("FEATURE_ALERT_GROUP_SEARCH_ENABLED", default=False)
FEATURE_NOTIFICATION_BUNDLE_ENABLED = getenv_boolean("FEATURE_NOTIFICATION_BUNDLE_ENABLED", default=False)

TWILIO_API_KEY_SID = os.environ.get("TWILIO_API_KEY_SID")
You are viewing a condensed version of this merge commit. You can view the full changes here.