mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Remove redundant code
bill_address is already joined in this query. The class variable isn't needed outside this scope. Arguably I think the condition on the select isn't needed; it wouldn't hurt to always select spree_addresses. But I'll try to avoid changing too much..
This commit is contained in:
@@ -15,21 +15,19 @@ class SearchOrders
|
||||
attr_reader :params, :current_user
|
||||
|
||||
def fetch_orders
|
||||
@search = search_query.
|
||||
search = search_query.
|
||||
includes(:payments, :subscription, :shipments, :bill_address, :distributor, :order_cycle).
|
||||
ransack(params[:q])
|
||||
|
||||
@search = @search.result(distinct: true)
|
||||
ransack(params[:q]).
|
||||
result(distinct: true)
|
||||
|
||||
if ['bill_address',
|
||||
'billing_address'].any?{ |param|
|
||||
params.dig(:q, :s)&.starts_with?(param)
|
||||
}
|
||||
@search = @search.left_joins(:bill_address).
|
||||
select('spree_addresses.*, spree_orders.*')
|
||||
search = search.select('spree_addresses.*, spree_orders.*')
|
||||
end
|
||||
|
||||
@search
|
||||
search
|
||||
end
|
||||
|
||||
def search_query
|
||||
|
||||
Reference in New Issue
Block a user