mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
20 lines
417 B
Ruby
20 lines
417 B
Ruby
class SubscriptionsCount
|
|
def initialize(order_cycles)
|
|
@order_cycles = order_cycles
|
|
end
|
|
|
|
def for(order_cycle_id)
|
|
active[order_cycle_id] || 0
|
|
end
|
|
|
|
private
|
|
|
|
attr_accessor :order_cycles
|
|
|
|
def active
|
|
return @active unless @active.nil?
|
|
return @active = [] if order_cycles.blank?
|
|
@active ||= ProxyOrder.not_canceled.group(:order_cycle_id).where(order_cycle_id: order_cycles).count
|
|
end
|
|
end
|