Class: Kaui::AnalyticsController

Inherits:
EngineController show all
Defined in:
app/controllers/kaui/analytics_controller.rb

Instance Method Summary collapse

Methods inherited from EngineController

#current_user

Methods included from ErrorHelper

#as_string

Instance Method Details

#accounts_over_timeObject



22
23
24
25
26
27
28
29
# File 'app/controllers/kaui/analytics_controller.rb', line 22

def accounts_over_time
  begin
    @accounts = Analytics.accounts_over_time
  rescue => e
    flash[:error] = "Error while retrieving data: #{as_string(e)}"
    @accounts = Kaui::TimeSeriesData.empty
  end
end

#indexObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/kaui/analytics_controller.rb', line 3

def index
  @slugs = []
  begin
    catalog = Kaui::KillbillHelper::get_full_catalog()
    catalog['products'].each do |product|
      product['plans'].each do |plan|
        name = plan['name']
        plan['phases'].each do |phase|
          type = phase['type']
          @slugs << "#{name.downcase}-#{type.downcase}"
        end
      end
    end
    @product_type = catalog['name']
  rescue => e
    flash[:error] = "Error while retrieving catalog: #{as_string(e)}"
  end
end

#subscriptions_over_timeObject



31
32
33
34
35
# File 'app/controllers/kaui/analytics_controller.rb', line 31

def subscriptions_over_time
  @product_type = params[:product_type]
  @slug = params[:slug]
  @subscriptions = Analytics.subscriptions_over_time(@product_type, @slug)
end