mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Replace LEFT JOIN with INNER JOIN
I see no reason why a LEFT might be needed and its the root cause of the awful performance.
This commit is contained in:
@@ -75,6 +75,12 @@ Spree::Order.class_eval do
|
||||
joins('LEFT OUTER JOIN spree_products ON (spree_products.id = spree_variants.product_id)')
|
||||
}
|
||||
|
||||
scope :with_line_items_variants_and_products, lambda {
|
||||
joins('INNER JOIN spree_line_items ON (spree_line_items.order_id = spree_orders.id)').
|
||||
joins('INNER JOIN spree_variants ON (spree_variants.id = spree_line_items.variant_id)').
|
||||
joins('INNER JOIN spree_products ON (spree_products.id = spree_variants.product_id)')
|
||||
}
|
||||
|
||||
scope :not_state, lambda { |state|
|
||||
where("state != ?", state)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ module Permissions
|
||||
# Find orders that the user can see
|
||||
def visible_orders
|
||||
Spree::Order.
|
||||
with_line_items_variants_and_products_outer.
|
||||
with_line_items_variants_and_products.
|
||||
where(visible_orders_where_values)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user