Skip to content

Commit f56d3e2

Browse files
update last_incident retrieval
1 parent 119ab22 commit f56d3e2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/sentry/incidents/subscription_processor.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,13 @@ def trigger_alert_threshold(
555555
if options.get("metric_alerts.rate_limit"):
556556
# If an incident was created for this rule, trigger type, and subscription
557557
# within the last 10 minutes, don't make another one
558-
last_incident: Incident | None = trigger.triggered_incidents.order_by(
559-
"-date_added"
560-
).first()
558+
last_it = (
559+
IncidentTrigger.objects.filter(alert_rule_trigger=trigger)
560+
.order_by("-incident_id")
561+
.select_related("incident")
562+
.first()
563+
)
564+
last_incident: Incident | None = last_it.incident if last_it else None
561565
last_incident_projects = (
562566
[project.id for project in last_incident.projects.all()] if last_incident else []
563567
)

0 commit comments

Comments
 (0)