diff --git a/app/services/charge_filters/event_matching_service.rb b/app/services/charge_filters/event_matching_service.rb index 929f96d5277..aeff21dc93c 100644 --- a/app/services/charge_filters/event_matching_service.rb +++ b/app/services/charge_filters/event_matching_service.rb @@ -33,6 +33,10 @@ def applicable_event_properties end def filters + # NOTE: when called from the cache invalidator, filters are already pre-loaded, + # we just return the preloaded list to avoid N+1 queries + return charge.filters if charge.association_cached?(:filters) + charge.filters.includes(values: :billable_metric_filter) end end