Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/sentry/workflow_engine/processors/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from collections import defaultdict
from datetime import datetime, timedelta

from django.db import models
from django.utils import timezone

from sentry import features
Expand Down Expand Up @@ -183,8 +184,11 @@ def filter_recently_fired_workflow_actions(
)
update_workflow_action_group_statuses(now, statuses_to_update, missing_statuses)

# TODO: somehow attach workflows so we can fire actions with the appropriate workflow env
return Action.objects.filter(id__in=list(action_to_workflow_ids.keys()))
return Action.objects.filter(id__in=list(action_to_workflow_ids.keys())).annotate(
workflow_id=models.F(
"dataconditiongroupaction__condition_group__workflowdataconditiongroup__workflow__id"
)
)


def get_available_action_integrations_for_org(organization: Organization) -> list[RpcIntegration]:
Expand Down
11 changes: 11 additions & 0 deletions tests/sentry/workflow_engine/processors/test_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def test(self):
set(DataConditionGroup.objects.all()), self.event_data
)
assert set(triggered_actions) == {self.action}
assert {getattr(action, "workflow_id") for action in triggered_actions} == {
self.workflow.id,
}

for status in [status_1, status_2]:
status.refresh_from_db()
Expand Down Expand Up @@ -103,6 +106,10 @@ def test_multiple_workflows_single_action__first_fire(self):
)
# dedupes action if both workflows will fire it
assert set(triggered_actions) == {self.action}
assert {getattr(action, "workflow_id") for action in triggered_actions} == {
self.workflow.id,
workflow.id,
}

assert WorkflowActionGroupStatus.objects.filter(action=self.action).count() == 2

Expand All @@ -125,6 +132,10 @@ def test_multiple_workflows_single_action__later_fire(self):
)
# fires one action for the workflow that can fire it
assert set(triggered_actions) == {self.action}
assert {getattr(action, "workflow_id") for action in triggered_actions} == {
self.workflow.id,
workflow.id,
}

assert WorkflowActionGroupStatus.objects.filter(action=self.action).count() == 2

Expand Down
Loading