Optimise by pre-loading required columns

Oh boy, that's a big change.
This commit is contained in:
David Cook
2024-04-04 17:18:32 +11:00
parent 917ca790af
commit 32b33de707
2 changed files with 10 additions and 8 deletions

View File

@@ -87,14 +87,16 @@ module Admin
# Optimise by pre-loading required columns
def product_query_includes
# TODO: add other fields used in columns? (eg supplier: [:name])
[
# variants: [
# :default_price,
# :stock_locations,
# :stock_items,
# :variant_overrides
# ]
:image,
:supplier,
{ variants: [
:default_price,
:primary_taxon,
:product,
:stock_items,
:tax_category,
] },
]
end

View File

@@ -22,7 +22,7 @@ describe 'As an admin, I can manage products', feature: :admin_style_v3 do
expect{
visit admin_products_url
}.to query_database 416.times # goodness me. Remember this includes user session updates etc.
}.to query_database 243.times # Remember this includes user session updates etc.
end
describe "sorting" do