@@ -361,9 +361,10 @@ def test_workflow_filtered_out(self):
361
361
362
362
def test_many_workflows (self ):
363
363
workflow_two , _ , _ , _ = self .create_detector_and_workflow (name_prefix = "two" )
364
- triggered_workflows = evaluate_workflow_triggers (
365
- {self .workflow , workflow_two }, self .event_data
366
- )
364
+ workflows = set (Workflow .objects .all ().select_related ("when_condition_group" ).distinct ())
365
+ with self .assertNumQueries (2 ):
366
+ # 1 query per workflow to fetch data conditions
367
+ triggered_workflows = evaluate_workflow_triggers (workflows , self .event_data )
367
368
368
369
assert triggered_workflows == {self .workflow , workflow_two }
369
370
@@ -535,6 +536,14 @@ def test_basic__no_filter(self):
535
536
triggered_actions = evaluate_workflows_action_filters ({self .workflow }, self .event_data )
536
537
assert set (triggered_actions ) == {self .action }
537
538
539
+ @patch ("sentry.workflow_engine.processors.workflow.filter_recently_fired_workflow_actions" )
540
+ def test_basic__num_queries (self , mock_filter ):
541
+ # isolate the number of queries in the outer function
542
+ with self .assertNumQueries (3 ):
543
+ # 2 queries for action conditions (including subquery to prefetch)
544
+ # 1 query for workflow data conditions
545
+ evaluate_workflows_action_filters ({self .workflow }, self .event_data )
546
+
538
547
def test_basic__with_filter__passes (self ):
539
548
self .create_data_condition (
540
549
condition_group = self .action_group ,
0 commit comments