Improve N+1 issues around #suppliers_of_products_distributed_by

There's still some real mess here with repeating queries, but resolving it is out of scope for this quick PR
This commit is contained in:
Matt-Yorkley
2019-11-29 17:10:23 +01:00
parent 51177b833e
commit 38c327dae0

View File

@@ -222,7 +222,8 @@ Spree::Admin::ReportsController.class_eval do
end
def suppliers_of_products_distributed_by(distributors)
distributors.map { |d| Spree::Product.in_distributor(d) }.flatten.map(&:supplier).uniq
distributors.map { |d| Spree::Product.in_distributor(d).includes(:supplier).all }.
flatten.map(&:supplier).uniq
end
# Load order cycles the current user has access to