From 6c1b7c4bf7b6a95e0b466165279155ae52c27e19 Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Fri, 1 Aug 2025 12:41:40 -0300 Subject: [PATCH] SIENTIAPDE-1174 feat: enhance notification filtering in Formatters and SlotManager classes - Added logic to remove receiver groups with no notifications, improving the efficiency of notification handling. - Implemented early return in Alerts and Reports workflows when there are no notifications or receiver groups, streamlining the processing flow. --- orchestrator/activities/formatters.py | 7 +++++++ orchestrator/activities/slot_manager.py | 7 +++++++ orchestrator/workflows/alerts.py | 3 +++ orchestrator/workflows/reports.py | 3 +++ 4 files changed, 20 insertions(+) diff --git a/orchestrator/activities/formatters.py b/orchestrator/activities/formatters.py index 1ebcc6b..04a983d 100644 --- a/orchestrator/activities/formatters.py +++ b/orchestrator/activities/formatters.py @@ -574,4 +574,11 @@ class Formatters(BaseActivity): notification) already_added_keys.append(key) + # Remove groups with no notifications + receiver_groups = { + group_name: group + for group_name, group in receiver_groups.items() + if group['notifications'] + } + return receiver_groups diff --git a/orchestrator/activities/slot_manager.py b/orchestrator/activities/slot_manager.py index 076a1a8..18e96d0 100644 --- a/orchestrator/activities/slot_manager.py +++ b/orchestrator/activities/slot_manager.py @@ -318,6 +318,13 @@ class SlotManager(Redis): notification) already_added_keys.append(key) + # Remove groups with no notifications + receiver_groups = { + group_name: group + for group_name, group in receiver_groups.items() + if group['notifications'] + } + return receiver_groups @activity.defn(name="store_notification_cache") diff --git a/orchestrator/workflows/alerts.py b/orchestrator/workflows/alerts.py index 6fbe231..1a8509a 100644 --- a/orchestrator/workflows/alerts.py +++ b/orchestrator/workflows/alerts.py @@ -82,6 +82,9 @@ class Alerts: } ) + if not log_report: + return + # Store the notification_id sendings to avoid sending them again await workflow.execute_activity_method( Activities.store_notification_cache, diff --git a/orchestrator/workflows/reports.py b/orchestrator/workflows/reports.py index 75e2851..eb00231 100644 --- a/orchestrator/workflows/reports.py +++ b/orchestrator/workflows/reports.py @@ -65,6 +65,9 @@ class Reports: retry_policy=retry_policy ) + if not receiver_groups: + return + # Call subworkflow "process_notifications" passing the notification package await workflow.execute_child_workflow( 'process_notifications',