Skip to content

Commit 86242c9

Browse files
committed
feat(products): eager load values in product filters query
## Context A product can have thousands of filters, each serialized with its values and their billable metric filters. Resolving those per row causes an N+1 on every paginated page. ## Description Eager load values and their billable_metric_filter in ProductFiltersQuery so both the GraphQL and REST list endpoints avoid the N+1 when rendering filter values.
1 parent aef7943 commit 86242c9

3 files changed

Lines changed: 498 additions & 498 deletions

File tree

app/queries/product_filters_query.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class ProductFiltersQuery < BaseQuery
55
Filters = BaseFilters[:product_id, :product_category_ids, :without_product_category]
66

77
def call
8-
product_filters = base_scope.result
8+
product_filters = base_scope.result.includes(values: :billable_metric_filter)
99
product_filters = paginate(product_filters)
1010
product_filters = apply_consistent_ordering(product_filters)
1111

0 commit comments

Comments
 (0)