Skip to content

Commit 7c65374

Browse files
committed
update for resolution conditions
1 parent 2adcc69 commit 7c65374

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/sentry/seer/anomaly_detection/store_data_workflow_engine.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from sentry.utils import json, metrics
3232
from sentry.utils.json import JSONDecodeError
3333
from sentry.workflow_engine.models import DataCondition, DataSource, DataSourceDetector, Detector
34-
from sentry.workflow_engine.types import DetectorException
34+
from sentry.workflow_engine.types import DetectorException, DetectorPriorityLevel
3535

3636
logger = logging.getLogger(__name__)
3737

@@ -64,10 +64,15 @@ def _fetch_related_models(
6464
)
6565
try:
6666
data_condition = DataCondition.objects.get(
67-
condition_group=detector.workflow_condition_group
67+
condition_group=detector.workflow_condition_group,
68+
condition_result__in=[
69+
DetectorPriorityLevel.HIGH,
70+
DetectorPriorityLevel.MEDIUM,
71+
DetectorPriorityLevel.LOW,
72+
],
6873
)
6974
except (DataCondition.DoesNotExist, DataCondition.MultipleObjectsReturned):
70-
# there should only ever be one data condition for a dynamic metric detector, we dont actually expect a MultipleObjectsReturned
75+
# there should only ever be one non-resolution data condition for a dynamic metric detector, we dont actually expect a MultipleObjectsReturned
7176
dcg_id = (
7277
detector.workflow_condition_group.id
7378
if detector.workflow_condition_group is not None

tests/sentry/incidents/endpoints/validators/test_validators.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,12 @@ def test_update_with_valid_data(self) -> None:
625625
"comparison": 100,
626626
"conditionResult": DetectorPriorityLevel.HIGH,
627627
},
628+
{
629+
"type": Condition.LESS_OR_EQUAL,
630+
"comparison": 100,
631+
"conditionResult": DetectorPriorityLevel.OK,
632+
"conditionGroupId": self.data_condition_group.id,
633+
},
628634
],
629635
},
630636
"name": new_name, # change the name
@@ -842,7 +848,7 @@ def test_anomaly_detection__send_historical_data_update_fails(
842848
assert condition_group.organization_id == self.project.organization_id
843849

844850
conditions = list(DataCondition.objects.filter(condition_group=condition_group))
845-
assert len(conditions) == 1
851+
assert len(conditions) == 2
846852
condition = conditions[0]
847853
assert condition.type == Condition.GREATER
848854
assert condition.comparison == 100

0 commit comments

Comments
 (0)