mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user