Skip to content

Commit d07840e

Browse files
committed
feat(products): eager load values in product item filters query
## Context A product item 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 ProductItemFiltersQuery so both the GraphQL and REST list endpoints avoid the N+1 when rendering filter values.
1 parent 8f1c0ec commit d07840e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

app/queries/product_item_filters_query.rb

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

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

0 commit comments

Comments
 (0)