From 263410b292f6d98839366edf72c57967e7c2358c Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Tue, 29 Jul 2025 12:13:08 -0300 Subject: [PATCH] SIENTIAPDE-1172 feat: enhance notification handling in Formatters and SlotManager classes - Introduced a mechanism to prevent duplicate notifications by tracking already added keys. - Updated notification filtering logic to ensure unique notifications are processed for each receiver group. - Improved overall notification management in orchestrator activities. --- orchestrator/activities/formatters.py | 7 ++++++- orchestrator/activities/slot_manager.py | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/orchestrator/activities/formatters.py b/orchestrator/activities/formatters.py index 17a091b..1ebcc6b 100644 --- a/orchestrator/activities/formatters.py +++ b/orchestrator/activities/formatters.py @@ -558,15 +558,20 @@ class Formatters(BaseActivity): } receiver_groups[group_name]['notifications'] = [] + already_added_keys = [] + ignore_list = receiver_group.get('ignore', []) for notification in notification_package: alert_type = "reports" notification_id = notification['notification_id'] + key = f"{notification['trigger']}:{notification_id}" + # Check if this group must be notified - if alert_type in receiver_group['contents'] and notification_id not in ignore_list: + if alert_type in receiver_group['contents'] and notification_id not in ignore_list and key not in already_added_keys: receiver_groups[group_name]["notifications"].append( notification) + already_added_keys.append(key) return receiver_groups diff --git a/orchestrator/activities/slot_manager.py b/orchestrator/activities/slot_manager.py index 16cf26f..076a1a8 100644 --- a/orchestrator/activities/slot_manager.py +++ b/orchestrator/activities/slot_manager.py @@ -289,6 +289,8 @@ class SlotManager(Redis): } receiver_groups[group_name]['notifications'] = [] + already_added_keys = [] + ignore_list = receiver_group.get('ignore', []) for notification in notification_package: @@ -311,9 +313,10 @@ class SlotManager(Redis): alert_type = "persistent_alerts" # Check if this group must be notified - if alert_type in receiver_group['contents'] and notification_id not in ignore_list: + if alert_type in receiver_group['contents'] and notification_id not in ignore_list and key not in already_added_keys: receiver_groups[group_name]["notifications"].append( notification) + already_added_keys.append(key) return receiver_groups