-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1716 from elementary-data/ele-3682-alerts-grouping
Ele 3682 alerts grouping
- Loading branch information
Showing
12 changed files
with
425 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from .alerts_group import AlertsGroup | ||
from .grouped_by_table import GroupedByTableAlerts | ||
|
||
__all__ = [ | ||
"AlertsGroup", | ||
"GroupedByTableAlerts", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
elementary/monitor/alerts/alerts_groups/grouped_by_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from typing import Optional | ||
|
||
from elementary.monitor.alerts.alerts_groups.alerts_group import AlertsGroup | ||
from elementary.monitor.data_monitoring.alerts.integrations.utils.report_link import ( | ||
ReportLinkData, | ||
get_model_test_runs_link, | ||
) | ||
from elementary.utils.models import get_shortened_model_name | ||
|
||
|
||
class GroupedByTableAlerts(AlertsGroup): | ||
@property | ||
def model_unique_id(self) -> Optional[str]: | ||
return self.alerts[0].model_unique_id | ||
|
||
@property | ||
def model(self) -> str: | ||
return get_shortened_model_name(self.model_unique_id) | ||
|
||
@property | ||
def report_url(self) -> Optional[str]: | ||
return self.alerts[0].report_url | ||
|
||
@property | ||
def summary(self) -> str: | ||
return f"{self.model}: {len(self.alerts)} issues detected" | ||
|
||
def get_report_link(self) -> Optional[ReportLinkData]: | ||
if not self.model_errors: | ||
return get_model_test_runs_link(self.report_url, self.model_unique_id) | ||
|
||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from enum import Enum | ||
|
||
|
||
class GroupingType(str, Enum): | ||
BY_ALERT = "alert" | ||
BY_TABLE = "table" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.