mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-13 04:00:21 +00:00
Use a SubscriptionsCount query object to provide counts to IndexOrderCycleSerializer
This commit is contained in:
@@ -19,7 +19,7 @@ module Admin
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json do
|
||||
render_as_json @collection, ams_prefix: params[:ams_prefix], current_user: spree_current_user, subscriptions_counts: subscriptions_counts
|
||||
render_as_json @collection, ams_prefix: params[:ams_prefix], current_user: spree_current_user, subscriptions_count: SubscriptionsCount.new(@collection)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -81,7 +81,7 @@ module Admin
|
||||
def bulk_update
|
||||
if order_cycle_set.andand.save
|
||||
respond_to do |format|
|
||||
format.json { render_as_json @order_cycles, ams_prefix: 'index', current_user: spree_current_user, subscriptions_counts: subscriptions_counts }
|
||||
format.json { render_as_json @order_cycles, ams_prefix: 'index', current_user: spree_current_user, subscriptions_count: SubscriptionsCount.new(@collection) }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
@@ -230,11 +230,6 @@ module Admin
|
||||
render json: { errors: t('admin.order_cycles.bulk_update.no_data') }, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
def subscriptions_counts
|
||||
return [] if @collection.blank?
|
||||
ProxyOrder.not_canceled.group(:order_cycle_id).where(order_cycle_id: @collection).count
|
||||
end
|
||||
|
||||
def ams_prefix_whitelist
|
||||
[:basic, :index]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user