Skip to content

Commit e29cc97

Browse files
committed
refactor: Extract _get_run_alert_subtitle_links method for better code organization
1 parent dc2348e commit e29cc97

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

  • elementary/monitor/alerts/alert_messages

elementary/monitor/alerts/alert_messages/builder.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ def _get_run_alert_subtitle_block(
125125
)
126126
return LinesBlock(lines=subtitle_lines)
127127

128+
def _get_run_alert_subtitle_links(
129+
self,
130+
alert: Union[TestAlertModel, SourceFreshnessAlertModel, ModelAlertModel],
131+
) -> List[ReportLinkData]:
132+
report_link = alert.get_report_link()
133+
if report_link:
134+
return [report_link]
135+
return []
136+
128137
def _get_run_alert_subtitle_blocks(
129138
self,
130139
alert: Union[TestAlertModel, SourceFreshnessAlertModel, ModelAlertModel],
@@ -140,7 +149,7 @@ def _get_run_alert_subtitle_blocks(
140149
elif isinstance(alert, ModelAlertModel):
141150
asset_type = "snapshot" if alert.materialization == "snapshot" else "model"
142151
asset_name = alert.alias
143-
report_link = alert.get_report_link()
152+
links = self._get_run_alert_subtitle_links(alert)
144153
return [
145154
self._get_run_alert_subtitle_block(
146155
type=asset_type,
@@ -149,7 +158,7 @@ def _get_run_alert_subtitle_blocks(
149158
detected_at_str=alert.detected_at_str,
150159
suppression_interval=alert.suppression_interval,
151160
env=alert.env,
152-
links=[report_link] if report_link else [],
161+
links=links,
153162
)
154163
]
155164

0 commit comments

Comments
 (0)