1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-04 15:24:23 +01:00
fab-manager/app/services/statistics/builders/subscriptions_builder_service.rb
2022-08-29 17:34:09 +02:00

24 lines
947 B
Ruby

# frozen_string_literal: true
# Generate statistics indicators about subscriptions
class Statistics::Builders::SubscriptionsBuilderService
include Statistics::Concerns::HelpersConcern
class << self
def build(options = default_options)
# subscription list
Statistics::FetcherService.subscriptions_list(options).each do |s|
Stats::Subscription.create({ date: format_date(s[:date]),
type: s[:duration],
subType: s[:slug],
stat: 1,
ca: s[:ca],
planId: s[:plan_id],
subscriptionId: s[:subscription_id],
invoiceItemId: s[:invoice_item_id],
groupName: s[:plan_group_name] }.merge(user_info_stat(s)))
end
end
end
end