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.
This commit is contained in:
@@ -574,4 +574,11 @@ class Formatters(BaseActivity):
|
|||||||
notification)
|
notification)
|
||||||
already_added_keys.append(key)
|
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
|
return receiver_groups
|
||||||
|
|||||||
@@ -318,6 +318,13 @@ class SlotManager(Redis):
|
|||||||
notification)
|
notification)
|
||||||
already_added_keys.append(key)
|
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
|
return receiver_groups
|
||||||
|
|
||||||
@activity.defn(name="store_notification_cache")
|
@activity.defn(name="store_notification_cache")
|
||||||
|
|||||||
@@ -82,6 +82,9 @@ class Alerts:
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if not log_report:
|
||||||
|
return
|
||||||
|
|
||||||
# Store the notification_id sendings to avoid sending them again
|
# Store the notification_id sendings to avoid sending them again
|
||||||
await workflow.execute_activity_method(
|
await workflow.execute_activity_method(
|
||||||
Activities.store_notification_cache,
|
Activities.store_notification_cache,
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ class Reports:
|
|||||||
retry_policy=retry_policy
|
retry_policy=retry_policy
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if not receiver_groups:
|
||||||
|
return
|
||||||
|
|
||||||
# Call subworkflow "process_notifications" passing the notification package
|
# Call subworkflow "process_notifications" passing the notification package
|
||||||
await workflow.execute_child_workflow(
|
await workflow.execute_child_workflow(
|
||||||
'process_notifications',
|
'process_notifications',
|
||||||
|
|||||||
Reference in New Issue
Block a user