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:
@@ -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
|
||||
|
||||
@@ -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'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user