SIENTIAPDE-1172
refactor: update email HTML structure and enhance notification generator - Modified email HTML to reflect updated model names and error/warning messages. - Adjusted notification generator to improve execution counts and streamline output handling. - Refactored activities in orchestrator to correct parameter names and improve type hints for better clarity. - Enhanced email builder to handle error, warning, and info models more efficiently.
This commit is contained in:
98
email.html
98
email.html
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<h3>Errors detected:</h3>
|
<h3>Errors detected:</h3>
|
||||||
|
|
||||||
<h4>Model: <span>ut aliqua ut ipsum</span></h4>
|
<h4>Model: <span>do elit</span></h4>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -30,16 +30,16 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>TAG_node5:tag_87_LISTENNING_STOPPED</td>
|
<td>REPORT_PARTITION_MANAGER</td>
|
||||||
<td>dolor_elit_aliqua</td>
|
<td>lorem_adipiscing</td>
|
||||||
<td>2025-07-25 16:50:48.925421+00:00</td>
|
<td>2025-07-28 20:05:38.650661+00:00</td>
|
||||||
<td>sit elit ipsum labore incididunt magna do et sit incididunt</td>
|
<td>incididunt dolor lorem incididunt elit incididunt dolor consectetur ipsum ut</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h4>Model: <span>elit dolore</span></h4>
|
<h4>Model: <span>dolor magna</span></h4>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -52,16 +52,16 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>OPC_LISTENNING_BACK__server_10</td>
|
<td>REPORT_PARTITION_MANAGER</td>
|
||||||
<td>magna_magna_et</td>
|
<td>tempor_dolore_eiusmod</td>
|
||||||
<td>2025-07-25 16:50:48.925478+00:00</td>
|
<td>2025-07-28 20:05:38.650910+00:00</td>
|
||||||
<td>aliqua eiusmod ut eiusmod ut et ipsum</td>
|
<td>ipsum amet ipsum aliqua et eiusmod</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h4>Model: <span>lorem lorem ipsum amet</span></h4>
|
<h4>Model: <span>labore sit lorem</span></h4>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -74,10 +74,10 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>TAG_node8:tag_11_LISTENNING_STOPPED</td>
|
<td>OPC_CONNECTION_RETRY__server_6</td>
|
||||||
<td>do_sit</td>
|
<td>dolor_labore_lorem</td>
|
||||||
<td>2025-07-25 16:50:48.925506+00:00</td>
|
<td>2025-07-28 20:05:38.650949+00:00</td>
|
||||||
<td>labore do adipiscing adipiscing incididunt eiusmod</td>
|
<td>et adipiscing ipsum ut aliqua ut adipiscing aliqua amet</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
|
|
||||||
<h3>Warnings detected:</h3>
|
<h3>Warnings detected:</h3>
|
||||||
|
|
||||||
<h4>Model: <span>amet eiusmod dolor ipsum</span></h4>
|
<h4>Model: <span>incididunt adipiscing elit sit</span></h4>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -98,16 +98,16 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>REPORT_PARTITION_MANAGER</td>
|
<td>ADIPISCING_AMET_IPSUM</td>
|
||||||
<td>adipiscing_amet_ut_et</td>
|
<td>eiusmod_aliqua_incididunt</td>
|
||||||
<td>2025-07-25 16:50:48.925368+00:00</td>
|
<td>2025-07-28 20:05:38.650621+00:00</td>
|
||||||
<td>eiusmod et amet sit lorem incididunt</td>
|
<td>magna incididunt dolore sed eiusmod sit incididunt ut</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h4>Model: <span>sit et labore</span></h4>
|
<h4>Model: <span>do adipiscing et</span></h4>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -120,16 +120,16 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>SIT_CONSECTETUR_EIUSMOD</td>
|
<td>TAG_node46:tag_73_LISTENNING_STOPPED</td>
|
||||||
<td>adipiscing_elit_ut</td>
|
<td>amet_dolor</td>
|
||||||
<td>2025-07-25 16:50:48.925392+00:00</td>
|
<td>2025-07-28 20:05:38.650706+00:00</td>
|
||||||
<td>magna do eiusmod et labore elit</td>
|
<td>dolore do et consectetur adipiscing do magna eiusmod eiusmod</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h4>Model: <span>consectetur labore do consectetur</span></h4>
|
<h4>Model: <span>lorem dolore amet</span></h4>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -142,16 +142,16 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>SED_SIT_DOLOR_CONSECTETUR</td>
|
<td>TAG_node13:tag_59_LISTENNING_STOPPED</td>
|
||||||
<td>dolor_dolore_ut</td>
|
<td>ipsum_tempor_ipsum</td>
|
||||||
<td>2025-07-25 16:50:48.925435+00:00</td>
|
<td>2025-07-28 20:05:38.650785+00:00</td>
|
||||||
<td>magna sed incididunt dolor tempor</td>
|
<td>et sed adipiscing tempor dolor magna do lorem</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h4>Model: <span>et sed ut et</span></h4>
|
<h4>Model: <span>eiusmod sed</span></h4>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -164,10 +164,10 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>UT_UT_LABORE</td>
|
<td>OPC_SUBSCRIPTION__server_2</td>
|
||||||
<td>sit_do</td>
|
<td>do_ipsum</td>
|
||||||
<td>2025-07-25 16:50:48.925492+00:00</td>
|
<td>2025-07-28 20:05:38.650826+00:00</td>
|
||||||
<td>do sed sed elit do eiusmod</td>
|
<td>eiusmod et consectetur do dolore dolor sed amet</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -175,7 +175,7 @@
|
|||||||
|
|
||||||
<h3>Infos detected:</h3>
|
<h3>Infos detected:</h3>
|
||||||
|
|
||||||
<h4>Model: <span>eiusmod eiusmod</span></h4>
|
<h4>Model: <span>et sed</span></h4>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -188,16 +188,16 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>OPC_CONNECTION_RETRY__server_2</td>
|
<td>OPC_LISTENNING_STOPPED__server_6</td>
|
||||||
<td>labore_sit_do</td>
|
<td>labore_do_ipsum_ipsum</td>
|
||||||
<td>2025-07-25 16:50:48.925407+00:00</td>
|
<td>2025-07-28 20:05:38.650570+00:00</td>
|
||||||
<td>magna et ipsum amet dolore adipiscing adipiscing do</td>
|
<td>tempor dolore eiusmod sit sit sed elit</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h4>Model: <span>adipiscing consectetur</span></h4>
|
<h4>Model: <span>dolore sit</span></h4>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -211,15 +211,15 @@
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>REPORT_PARTITION_MANAGER</td>
|
<td>REPORT_PARTITION_MANAGER</td>
|
||||||
<td>incididunt_aliqua_ipsum_ut</td>
|
<td>et_lorem_incididunt_ipsum</td>
|
||||||
<td>2025-07-25 16:50:48.925447+00:00</td>
|
<td>2025-07-28 20:05:38.650742+00:00</td>
|
||||||
<td>labore magna adipiscing tempor elit et et magna elit lorem</td>
|
<td>adipiscing magna adipiscing adipiscing sit tempor</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h4>Model: <span>et amet</span></h4>
|
<h4>Model: <span>adipiscing do</span></h4>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -232,10 +232,10 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>OPC_LISTENNING_BACK__server_2</td>
|
<td>TAG_node76:tag_73_LISTENNING_STOPPED</td>
|
||||||
<td>sed_elit_ut_do</td>
|
<td>tempor_elit</td>
|
||||||
<td>2025-07-25 16:50:48.925462+00:00</td>
|
<td>2025-07-28 20:05:38.650875+00:00</td>
|
||||||
<td>dolor et adipiscing adipiscing dolore ipsum ipsum aliqua et elit</td>
|
<td>et do aliqua lorem incididunt</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -73,9 +73,9 @@ class Activities( # Couchbase,
|
|||||||
Postgres.__init__(self,
|
Postgres.__init__(self,
|
||||||
host=postgres_config['host'],
|
host=postgres_config['host'],
|
||||||
port=postgres_config['port'],
|
port=postgres_config['port'],
|
||||||
user=postgres_config['username'],
|
user=postgres_config['user'],
|
||||||
password=postgres_config['password'],
|
password=postgres_config['password'],
|
||||||
dbname=postgres_config['database_name'],
|
dbname=postgres_config['dbname'],
|
||||||
min_connections=postgres_config['min_connections'],
|
min_connections=postgres_config['min_connections'],
|
||||||
max_connections=postgres_config['max_connections'],
|
max_connections=postgres_config['max_connections'],
|
||||||
logger=logger,
|
logger=logger,
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class Email(BaseActivity):
|
|||||||
notification_handler=notification_handler)
|
notification_handler=notification_handler)
|
||||||
|
|
||||||
@activity.defn(name="build_email_html")
|
@activity.defn(name="build_email_html")
|
||||||
async def build_email_html(self, input_data: dict[str, Any]) -> str:
|
async def build_email_html(self, input_data: dict[str, Any]) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
Builds the email html for each receiver group.
|
Builds the email html for each receiver group.
|
||||||
input_data:
|
input_data:
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ class SlotManager(Redis):
|
|||||||
return receiver_groups
|
return receiver_groups
|
||||||
|
|
||||||
@activity.defn(name="store_notification_cache")
|
@activity.defn(name="store_notification_cache")
|
||||||
async def store_notification_cache(self, input_data: dict[str, Any]) -> dict[str, Any]:
|
async def store_notification_cache(self, input_data: dict[str, Any]) -> None:
|
||||||
"""
|
"""
|
||||||
Store notification cache
|
Store notification cache
|
||||||
"""
|
"""
|
||||||
@@ -335,5 +335,3 @@ class SlotManager(Redis):
|
|||||||
if status == 'sent':
|
if status == 'sent':
|
||||||
key = f"{row['schedule']}:{row['notification_id']}"
|
key = f"{row['schedule']}:{row['notification_id']}"
|
||||||
self.set(key, now, ttl=sent_ttl)
|
self.set(key, now, ttl=sent_ttl)
|
||||||
|
|
||||||
return log_report
|
|
||||||
|
|||||||
@@ -24,14 +24,18 @@ class EmailBuilder:
|
|||||||
return template.render(parameters)
|
return template.render(parameters)
|
||||||
|
|
||||||
def parameters(self, general_events: dict, mail_type: str) -> dict:
|
def parameters(self, general_events: dict, mail_type: str) -> dict:
|
||||||
|
error_models = general_events.get('ERROR', {}).get('models', [])
|
||||||
|
warning_models = general_events.get('WARNING', {}).get('models', [])
|
||||||
|
info_models = general_events.get('INFO', {}).get('models', [])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'mail_type': mail_type,
|
'mail_type': mail_type,
|
||||||
'error_events': self.replace_parameters(self.general_template,
|
'error_events': self.replace_parameters(self.general_template,
|
||||||
general_events['ERROR']) if general_events['ERROR']['models'] else '',
|
error_models) if error_models else '',
|
||||||
'warning_events': self.replace_parameters(self.general_template,
|
'warning_events': self.replace_parameters(self.general_template,
|
||||||
general_events['WARNING']) if general_events['WARNING']['models'] else '',
|
warning_models) if warning_models else '',
|
||||||
'info_events': self.replace_parameters(self.general_template,
|
'info_events': self.replace_parameters(self.general_template,
|
||||||
general_events['INFO']) if general_events['INFO']['models'] else '',
|
info_models) if info_models else '',
|
||||||
}
|
}
|
||||||
|
|
||||||
def build_email(self, report_data: list[dict], mail_type: str) -> str:
|
def build_email(self, report_data: list[dict], mail_type: str) -> str:
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ from temporalio import workflow
|
|||||||
with workflow.unsafe.imports_passed_through():
|
with workflow.unsafe.imports_passed_through():
|
||||||
from orchestrator.activities.activities import Activities
|
from orchestrator.activities.activities import Activities
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
from datetime import timedelta
|
||||||
|
from sientia_do.temporal.utils.policies import retry_policy
|
||||||
|
|
||||||
|
|
||||||
@workflow.defn(name="alerts")
|
@workflow.defn(name="alerts")
|
||||||
@@ -62,7 +64,9 @@ class Alerts:
|
|||||||
'notification_package': package['notification_package'],
|
'notification_package': package['notification_package'],
|
||||||
'sending_configs': package['sending_configs'],
|
'sending_configs': package['sending_configs'],
|
||||||
'notification_ttl': input_data['notification_ttl']
|
'notification_ttl': input_data['notification_ttl']
|
||||||
}
|
},
|
||||||
|
schedule_to_close_timeout=timedelta(seconds=60),
|
||||||
|
retry_policy=retry_policy
|
||||||
)
|
)
|
||||||
|
|
||||||
# Call subworkflow "process_notifications" passing the notification package
|
# Call subworkflow "process_notifications" passing the notification package
|
||||||
@@ -84,5 +88,7 @@ class Alerts:
|
|||||||
**metadata,
|
**metadata,
|
||||||
'log_report': log_report,
|
'log_report': log_report,
|
||||||
'sent_ttl': input_data['sent_ttl']
|
'sent_ttl': input_data['sent_ttl']
|
||||||
}
|
},
|
||||||
|
schedule_to_close_timeout=timedelta(seconds=60),
|
||||||
|
retry_policy=retry_policy
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -75,6 +75,15 @@ class LoadNotificationPackage:
|
|||||||
'sending_configs': await sending_configs_handler
|
'sending_configs': await sending_configs_handler
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sending_configs = await sending_configs_handler
|
||||||
|
|
||||||
|
if not sending_configs or not notification_package:
|
||||||
|
return {
|
||||||
|
'last_timestamp': last_timestamp,
|
||||||
|
'notification_package': notification_package,
|
||||||
|
'sending_configs': sending_configs
|
||||||
|
}
|
||||||
|
|
||||||
# Put last collected timestamp in redis "notification_last_timestamp"
|
# Put last collected timestamp in redis "notification_last_timestamp"
|
||||||
|
|
||||||
await workflow.start_activity_method(
|
await workflow.start_activity_method(
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ class ProcessNotifications:
|
|||||||
Activities.build_email_html,
|
Activities.build_email_html,
|
||||||
{
|
{
|
||||||
**metadata,
|
**metadata,
|
||||||
"receiver_groups": input_data["notification_package"]
|
"receiver_groups": input_data["notification_package"],
|
||||||
|
"mail_type": input_data["mail_type"]
|
||||||
},
|
},
|
||||||
schedule_to_close_timeout=timedelta(seconds=60),
|
schedule_to_close_timeout=timedelta(seconds=60),
|
||||||
retry_policy=retry_policy
|
retry_policy=retry_policy
|
||||||
@@ -68,6 +69,8 @@ class ProcessNotifications:
|
|||||||
"receiver_groups": log_report,
|
"receiver_groups": log_report,
|
||||||
"mail_type": input_data["mail_type"]
|
"mail_type": input_data["mail_type"]
|
||||||
},
|
},
|
||||||
|
schedule_to_close_timeout=timedelta(seconds=60),
|
||||||
|
retry_policy=retry_policy
|
||||||
)
|
)
|
||||||
|
|
||||||
# Store sending log in postgres database "log_report"
|
# Store sending log in postgres database "log_report"
|
||||||
|
|||||||
Reference in New Issue
Block a user