Browse Source

fix(workflow): Round metric alert interval (#34724)

Scott Cooper 2 years ago
parent
commit
8f2117ac7e
2 changed files with 3 additions and 3 deletions
  1. 1 1
      src/sentry/incidents/charts.py
  2. 2 2
      tests/sentry/integrations/slack/test_unfurl.py

+ 1 - 1
src/sentry/incidents/charts.py

@@ -189,7 +189,7 @@ def build_metric_alert_chart(
     aggregate = translate_aggregate_field(snuba_query.aggregate, reverse=True)
     # If we allow alerts to be across multiple orgs this will break
     project_id = snuba_query.subscriptions.first().project_id
-    time_window_minutes = snuba_query.time_window / 60
+    time_window_minutes = snuba_query.time_window // 60
     env_params = {"environment": snuba_query.environment.name} if snuba_query.environment else {}
     query = (
         snuba_query.query

+ 2 - 2
tests/sentry/integrations/slack/test_unfurl.py

@@ -287,7 +287,7 @@ class UnfurlTest(TestCase):
             query="",
             aggregate="percentage(sessions_crashed, sessions) AS _crash_rate_alert_aggregate",
             dataset=QueryDatasets.SESSIONS,
-            time_window=1,
+            time_window=60,
             resolve_threshold=10,
             threshold_period=1,
         )
@@ -325,7 +325,7 @@ class UnfurlTest(TestCase):
         chart_data = mock_generate_chart.call_args[0][1]
         assert chart_data["rule"]["id"] == str(alert_rule.id)
         assert chart_data["selectedIncident"] is None
-        assert len(chart_data["sessionResponse"]["groups"]) >= 2
+        assert len(chart_data["sessionResponse"]["groups"]) >= 1
         assert len(chart_data["incidents"]) == 0
 
     @patch("sentry.integrations.slack.unfurl.discover.generate_chart", return_value="chart-url")