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

#account_snapshotObject



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

def 
  # params[:account_id] can either be a uuid or an external key
  begin
    @account = Kaui::KillbillHelper::(params[:account_id])
    @snapshot = Kaui::KillbillHelper::(@account.)
  rescue => e
    flash[:error] = "Error while retrieving account snapshot: #{as_string(e)}"
    redirect_to :analytics
  end
end

#accounts_over_timeObject



43
44
45
46
47
48
49
50
# File 'app/controllers/kaui/analytics_controller.rb', line 43

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

#refresh_accountObject



33
34
35
36
37
38
39
40
41
# File 'app/controllers/kaui/analytics_controller.rb', line 33

def 
  begin
    Kaui::KillbillHelper::(params[:account_id])
    flash[:notice] = "Account successfully refreshed!"
  rescue => e
    flash[:error] = "Error while refreshing account: #{as_string(e)}"
  end
  redirect_to (:account_id => params[:account_id])
end

#sanityObject



58
59
60
61
62
63
64
65
# File 'app/controllers/kaui/analytics_controller.rb', line 58

def sanity
  begin
    @sanity = Kaui::KillbillHelper::check_analytics_sanity
  rescue => e
    flash[:error] = "Error while checking Analytics sanity: #{as_string(e)}"
    redirect_to :analytics
  end
end

#subscriptions_over_timeObject



52
53
54
55
56
# File 'app/controllers/kaui/analytics_controller.rb', line 52

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