SIENTIAPDE-1172

feat: enhance email notifications and orchestrator activities for reports

- Updated email HTML structure to clearly present errors, warnings, and info notifications.
- Introduced a new method in the Formatters class to filter notification reports based on group configurations.
- Enhanced the Reports workflow to integrate the new filtering functionality and manage notification packages effectively.
- Adjusted SlotManager to store timestamps with mail type specificity for better tracking.
- Improved test coverage for the new filtering functionality in the Formatters class.
This commit is contained in:
vitor-aignosi
2025-07-29 11:42:05 -03:00
parent bc456cc8be
commit 6f6094b2ce
9 changed files with 527 additions and 10 deletions

View File

@@ -532,6 +532,41 @@ class Formatters(BaseActivity):
'mail_type': mail_type
}
else:
data[key]['groups'].append(group_name)
if group_name not in data[key]['groups']:
data[key]['groups'].append(group_name)
return DataFrame(list(data.values())).to_dict()
@activity.defn(name="filter_notification_reports")
async def filter_notification_reports(self, input_data: dict[str, Any]) -> dict[str, Any]:
"""
Filter notification reports.
"""
metadata = input_data['metadata']
notification_package = input_data['notification_package']
sending_configs = input_data['sending_configs']
self.info("Filtering notification reports...", metadata=metadata)
receiver_groups = {}
for receiver_group in sending_configs:
group_name = receiver_group['group_name']
receiver_groups[group_name] = {
**receiver_group,
"notifications": []
}
receiver_groups[group_name]['notifications'] = []
ignore_list = receiver_group.get('ignore', [])
for notification in notification_package:
alert_type = "reports"
notification_id = notification['notification_id']
# Check if this group must be notified
if alert_type in receiver_group['contents'] and notification_id not in ignore_list:
receiver_groups[group_name]["notifications"].append(
notification)
return receiver_groups

View File

@@ -204,7 +204,7 @@ class SlotManager(Redis):
Gets the last data timestamp from redis.
"""
metadata = input_data['metadata']
key = "notification_last_timestamp"
key = f"notification_last_timestamp:{input_data['mail_type']}"
try:
data_hold = self.get(key)
@@ -235,7 +235,7 @@ class SlotManager(Redis):
Puts the last data timestamp into redis.
"""
metadata = input_data['metadata']
key = "notification_last_timestamp"
key = f"notification_last_timestamp:{input_data['mail_type']}"
data = DataFrame(input_data['data'])