mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-02 02:11:33 +00:00
Remove N+1 fetching order and li adjustments
This commit is contained in:
committed by
François Turbelin
parent
b4952dcbfb
commit
00c9dd7ece
@@ -20,10 +20,15 @@ class OrderTaxAdjustmentsFetcher
|
||||
attr_reader :order
|
||||
|
||||
def all
|
||||
order.adjustments.with_tax +
|
||||
order.line_items.includes(:adjustments).map { |li|
|
||||
li.adjustments.with_tax
|
||||
}.flatten
|
||||
Spree::Adjustment
|
||||
.with_tax
|
||||
.where(adjustable_id: order.id, adjustable_type: 'Spree::Order')
|
||||
.order('created_at ASC') +
|
||||
|
||||
Spree::Adjustment
|
||||
.with_tax
|
||||
.where(adjustable_id: order.line_item_ids, adjustable_type: 'Spree::LineItem')
|
||||
.order('created_at ASC')
|
||||
end
|
||||
|
||||
def tax_rates_hash(adjustment)
|
||||
|
||||
Reference in New Issue
Block a user