From 44bd52966cb5a918d7fc65000ba1c13aade9808c Mon Sep 17 00:00:00 2001 From: Daniel Pollak Date: Tue, 15 Oct 2024 16:16:26 +0300 Subject: [PATCH 1/2] use class method --- .../alerts/integrations/slack/slack.py | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/elementary/monitor/data_monitoring/alerts/integrations/slack/slack.py b/elementary/monitor/data_monitoring/alerts/integrations/slack/slack.py index a7a6bad7c..be23fd01d 100644 --- a/elementary/monitor/data_monitoring/alerts/integrations/slack/slack.py +++ b/elementary/monitor/data_monitoring/alerts/integrations/slack/slack.py @@ -23,7 +23,6 @@ from elementary.monitor.data_monitoring.alerts.integrations.utils.report_link import ( get_model_runs_link, get_model_test_runs_link, - get_test_runs_link, ) from elementary.tracking.tracking_interface import Tracking from elementary.utils.json_utils import ( @@ -147,9 +146,8 @@ def _get_dbt_test_template( ), ) - test_runs_report_link = get_test_runs_link( - alert.report_url, alert.elementary_unique_id - ) + test_runs_report_link = alert.get_report_link() + if test_runs_report_link: report_link = self.message_builder.create_context_block( [ @@ -313,9 +311,8 @@ def _get_elementary_test_template( ), ) - test_runs_report_link = get_test_runs_link( - alert.report_url, alert.elementary_unique_id - ) + test_runs_report_link = alert.get_report_link() + if test_runs_report_link: report_link = self.message_builder.create_context_block( [ @@ -460,9 +457,8 @@ def _get_model_template( ), ) - model_runs_report_link = get_model_runs_link( - alert.report_url, alert.model_unique_id - ) + model_runs_report_link = alert.get_report_link() + if model_runs_report_link: report_link = self.message_builder.create_context_block( [ @@ -564,9 +560,8 @@ def _get_snapshot_template( ), ) - model_runs_report_link = get_model_runs_link( - alert.report_url, alert.model_unique_id - ) + model_runs_report_link = alert.get_report_link() + if model_runs_report_link: report_link = self.message_builder.create_context_block( [ @@ -652,9 +647,8 @@ def _get_source_freshness_template( ), ) - test_runs_report_link = get_test_runs_link( - alert.report_url, alert.source_freshness_execution_id - ) + test_runs_report_link = alert.get_report_link() + if test_runs_report_link: report_link = self.message_builder.create_context_block( [ From d37ead394b5d6bfa52bff2d811730210d2ce4614 Mon Sep 17 00:00:00 2001 From: Daniel Pollak Date: Tue, 15 Oct 2024 16:22:07 +0300 Subject: [PATCH 2/2] lint --- .../monitor/data_monitoring/alerts/integrations/slack/slack.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/elementary/monitor/data_monitoring/alerts/integrations/slack/slack.py b/elementary/monitor/data_monitoring/alerts/integrations/slack/slack.py index be23fd01d..393328eb1 100644 --- a/elementary/monitor/data_monitoring/alerts/integrations/slack/slack.py +++ b/elementary/monitor/data_monitoring/alerts/integrations/slack/slack.py @@ -21,7 +21,6 @@ SlackAlertMessageSchema, ) from elementary.monitor.data_monitoring.alerts.integrations.utils.report_link import ( - get_model_runs_link, get_model_test_runs_link, ) from elementary.tracking.tracking_interface import Tracking @@ -561,7 +560,7 @@ def _get_snapshot_template( ) model_runs_report_link = alert.get_report_link() - + if model_runs_report_link: report_link = self.message_builder.create_context_block( [