Apply code style following Rubocop

This commit is contained in:
Maikel Linke
2016-03-09 12:42:16 +11:00
parent d925c2aefc
commit f1cc3a7b0d
2 changed files with 7 additions and 3 deletions

View File

@@ -56,10 +56,10 @@ module InjectionHelper
data_array = spree_current_user.orders_by_distributor.to_a
data_array.each do |enterprise|
enterprise.distributed_orders.each do |order|
order.payments.keep_if{ |payment| payment.state == "completed" }
order.payments.keep_if { |payment| payment.state == "completed" }
end
end
data_array.sort!{ |a, b| b.distributed_orders.length <=> a.distributed_orders.length }
data_array.sort! { |a, b| b.distributed_orders.length <=> a.distributed_orders.length }
inject_json_ams "orders_by_distributor", data_array, Api::OrdersByDistributorSerializer
end

View File

@@ -56,7 +56,11 @@ Spree.user_class.class_eval do
# Returns orders and their associated payments for all distributors that have been ordered from
def orders_by_distributor
Enterprise.includes(distributed_orders: :payments).where(enterprises: { id: self.enterprises_ordered_from }, spree_orders: { state: 'complete', user_id: self.id }).order('spree_orders.completed_at DESC')
Enterprise.includes(distributed_orders: :payments).
where(
enterprises: { id: self.enterprises_ordered_from },
spree_orders: { state: 'complete', user_id: self.id }).
order('spree_orders.completed_at DESC')
end
private