Skip to content

Commit

Permalink
ref(rules): Return stringified status (#55549)
Browse files Browse the repository at this point in the history
Return the string "active" or "disabled" rather than the enum value.
  • Loading branch information
ceorourke committed Aug 31, 2023
1 parent fc24d26 commit 908937d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/sentry/api/serializers/models/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from rest_framework import serializers

from sentry.api.serializers import Serializer, register
from sentry.constants import ObjectStatus
from sentry.models import (
ACTOR_TYPES,
Environment,
Expand Down Expand Up @@ -175,7 +176,7 @@ def serialize(self, obj, attrs, user, **kwargs):
"createdBy": attrs.get("created_by", None),
"environment": environment.name if environment is not None else None,
"projects": [obj.project.slug],
"status": obj.status,
"status": "active" if obj.status == ObjectStatus.ACTIVE else "disabled",
}
if "last_triggered" in attrs:
d["lastTriggered"] = attrs["last_triggered"]
Expand Down
2 changes: 1 addition & 1 deletion tests/sentry/api/endpoints/test_project_rule_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_with_environment(self):
)
assert response.data["id"] == str(self.rule.id)
assert response.data["environment"] == self.environment.name
assert response.data["status"] == ObjectStatus.ACTIVE
assert response.data["status"] == "active"

def test_with_filters(self):
conditions: list[dict[str, Any]] = [
Expand Down
3 changes: 1 addition & 2 deletions tests/sentry/api/serializers/test_alert_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
CombinedRuleSerializer,
DetailedAlertRuleSerializer,
)
from sentry.constants import ObjectStatus
from sentry.incidents.logic import create_alert_rule_trigger
from sentry.incidents.models import AlertRule, AlertRuleThresholdType
from sentry.models import Rule
Expand Down Expand Up @@ -221,6 +220,6 @@ def test_combined_serializer(self):

self.assert_alert_rule_serialized(alert_rule, result[0])
assert result[1]["id"] == str(issue_rule.id)
assert result[1]["status"] == ObjectStatus.ACTIVE
assert result[1]["status"] == "active"
assert not result[1]["snooze"]
self.assert_alert_rule_serialized(other_alert_rule, result[2])

0 comments on commit 908937d

Please sign in to comment.