Class: Kaui::AnalyticsController
- Inherits:
-
EngineController
- Object
- ApplicationController
- EngineController
- Kaui::AnalyticsController
- Defined in:
- app/controllers/kaui/analytics_controller.rb
Instance Method Summary collapse
- #account_snapshot ⇒ Object
- #accounts_over_time ⇒ Object
- #index ⇒ Object
- #refresh_account ⇒ Object
- #sanity ⇒ Object
- #subscriptions_over_time ⇒ Object
Methods inherited from EngineController
Methods included from ErrorHelper
Instance Method Details
#account_snapshot ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/kaui/analytics_controller.rb', line 22 def account_snapshot # params[:account_id] can either be a uuid or an external key begin @account = Kaui::KillbillHelper::get_account_by_key(params[:account_id]) @snapshot = Kaui::KillbillHelper::get_account_snapshot(@account.account_id) rescue => e flash[:error] = "Error while retrieving account snapshot: #{as_string(e)}" redirect_to :analytics end end |
#accounts_over_time ⇒ Object
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 |
#index ⇒ Object
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_account ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/kaui/analytics_controller.rb', line 33 def refresh_account begin Kaui::KillbillHelper::refresh_account(params[:account_id]) flash[:notice] = "Account successfully refreshed!" rescue => e flash[:error] = "Error while refreshing account: #{as_string(e)}" end redirect_to account_snapshot_path(:account_id => params[:account_id]) end |
#sanity ⇒ Object
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_time ⇒ Object
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 |