16
16
DataConditionGroup ,
17
17
Detector ,
18
18
Workflow ,
19
+ WorkflowDataConditionGroup ,
19
20
)
20
21
from sentry .workflow_engine .processors .action import filter_recently_fired_workflow_actions
21
22
from sentry .workflow_engine .processors .data_condition_group import process_data_condition_group
@@ -73,6 +74,8 @@ def evaluate_workflow_triggers(workflows: set[Workflow], job: WorkflowJob) -> se
73
74
if evaluation :
74
75
triggered_workflows .add (workflow )
75
76
77
+ job .pop ("workflow" , None )
78
+
76
79
return triggered_workflows
77
80
78
81
@@ -82,14 +85,25 @@ def evaluate_workflows_action_filters(
82
85
) -> BaseQuerySet [Action ]:
83
86
filtered_action_groups : set [DataConditionGroup ] = set ()
84
87
85
- # gets the list of the workflow ids, and then get the workflow_data_condition_groups for those workflows
86
- workflow_ids = {workflow .id for workflow in workflows }
88
+ # Gets the list of the workflow ids, and then get the workflow_data_condition_groups for those workflows
89
+ workflow_ids_to_workflows = {workflow .id : workflow for workflow in workflows }
87
90
88
91
action_conditions = DataConditionGroup .objects .filter (
89
- workflowdataconditiongroup__workflow_id__in = workflow_ids
92
+ workflowdataconditiongroup__workflow_id__in = list ( workflow_ids_to_workflows . keys ())
90
93
).distinct ()
91
94
95
+ workflow_to_dcg = dict (
96
+ WorkflowDataConditionGroup .objects .filter (
97
+ condition_group_id__in = action_conditions
98
+ ).values_list ("condition_group_id" , "workflow" )
99
+ )
100
+
92
101
for action_condition in action_conditions :
102
+ # Populate the workflow in the job for the action_condition evaluation
103
+ workflow_id = workflow_to_dcg .get (action_condition .id )
104
+ if workflow_id :
105
+ job ["workflow" ] = workflow_ids_to_workflows [workflow_id ]
106
+
93
107
(evaluation , result ), remaining_conditions = process_data_condition_group (
94
108
action_condition .id , job
95
109
)
@@ -109,6 +123,8 @@ def evaluate_workflows_action_filters(
109
123
if evaluation :
110
124
filtered_action_groups .add (action_condition )
111
125
126
+ job .pop ("workflow" , None )
127
+
112
128
return filter_recently_fired_workflow_actions (filtered_action_groups , job ["event" ].group )
113
129
114
130
0 commit comments