Skip to content

Commit 7a96b52

Browse files
committed
simplify
1 parent d398fa9 commit 7a96b52

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

src/sentry/workflow_engine/processors/action.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def get_unique_active_actions(
192192
def fire_actions(
193193
actions: BaseQuerySet[Action],
194194
event_data: WorkflowEventData,
195-
workflow_uuid_map: dict[int, str] | None = None,
195+
workflow_uuid_map: dict[int, str],
196196
) -> None:
197197
deduped_actions = get_unique_active_actions(actions)
198198

src/sentry/workflow_engine/tasks/actions.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
def build_trigger_action_task_params(
2626
action: Action,
2727
event_data: WorkflowEventData,
28-
workflow_uuid_map: dict[int, str] | None = None,
28+
workflow_uuid_map: dict[int, str],
2929
) -> dict[str, object]:
3030
"""
3131
Build parameters for trigger_action task invocation.
3232
3333
Args:
3434
action: The action to trigger.
3535
event_data: The event data to use for the action.
36-
workflow_uuid_map: Optional mapping of workflow_id to notification_uuid.
36+
workflow_uuid_map: Mapping of workflow_id to notification_uuid.
3737
"""
3838
event_id = None
3939
activity_id = None
@@ -45,9 +45,12 @@ def build_trigger_action_task_params(
4545
elif isinstance(event_data.event, Activity):
4646
activity_id = event_data.event.id
4747

48+
# workflow_id is annotated in the queryset by filter_recently_fired_workflow_actions
49+
workflow_id = getattr(action, "workflow_id", None)
50+
4851
task_params = {
4952
"action_id": action.id,
50-
"workflow_id": getattr(action, "workflow_id", None),
53+
"workflow_id": workflow_id,
5154
"event_id": event_id,
5255
"activity_id": activity_id,
5356
"group_id": event_data.event.group_id,
@@ -58,11 +61,8 @@ def build_trigger_action_task_params(
5861
}
5962

6063
# Add notification_uuid if available from workflow_uuid_map
61-
# workflow_id is annotated in the queryset by filter_recently_fired_workflow_actions
62-
if workflow_uuid_map:
63-
workflow_id = getattr(action, "workflow_id", None)
64-
if workflow_id is not None and workflow_id in workflow_uuid_map:
65-
task_params["notification_uuid"] = workflow_uuid_map[workflow_id]
64+
if workflow_id is not None and workflow_id in workflow_uuid_map:
65+
task_params["notification_uuid"] = workflow_uuid_map[workflow_id]
6666

6767
return task_params
6868

tests/sentry/workflow_engine/tasks/test_actions.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def setUp(self) -> None:
1414
self.group = self.create_group(project=self.project)
1515

1616
def test_build_trigger_action_task_params_basic(self) -> None:
17-
"""Test basic parameter building without workflow_uuid_map"""
1817
mock_group_event = Mock(spec=GroupEvent)
1918
mock_group_event.event_id = "event-123"
2019
mock_group_event.occurrence_id = "occurrence-456"
@@ -26,7 +25,7 @@ def test_build_trigger_action_task_params_basic(self) -> None:
2625
# Annotate workflow_id on action as the queryset would
2726
setattr(action, "workflow_id", 42)
2827

29-
params = build_trigger_action_task_params(action, event_data)
28+
params = build_trigger_action_task_params(action, event_data, {})
3029

3130
assert params["action_id"] == 1
3231
assert params["workflow_id"] == 42
@@ -36,7 +35,6 @@ def test_build_trigger_action_task_params_basic(self) -> None:
3635
assert "notification_uuid" not in params
3736

3837
def test_build_trigger_action_task_params_with_workflow_uuid_map(self) -> None:
39-
"""Test that notification_uuid is added when workflow_id is in workflow_uuid_map"""
4038
mock_group_event = Mock(spec=GroupEvent)
4139
mock_group_event.event_id = "event-123"
4240
mock_group_event.occurrence_id = "occurrence-456"
@@ -58,7 +56,6 @@ def test_build_trigger_action_task_params_with_workflow_uuid_map(self) -> None:
5856
assert params["notification_uuid"] == expected_notification_uuid
5957

6058
def test_build_trigger_action_task_params_workflow_not_in_map(self) -> None:
61-
"""Test that notification_uuid is not added when workflow_id is not in workflow_uuid_map"""
6259
mock_group_event = Mock(spec=GroupEvent)
6360
mock_group_event.event_id = "event-123"
6461
mock_group_event.occurrence_id = "occurrence-456"
@@ -80,7 +77,6 @@ def test_build_trigger_action_task_params_workflow_not_in_map(self) -> None:
8077
assert "notification_uuid" not in params
8178

8279
def test_build_trigger_action_task_params_no_workflow_id(self) -> None:
83-
"""Test that notification_uuid is not added when action has no workflow_id"""
8480
mock_group_event = Mock(spec=GroupEvent)
8581
mock_group_event.event_id = "event-123"
8682
mock_group_event.occurrence_id = "occurrence-456"

0 commit comments

Comments
 (0)