Class: Kaui::Analytics
- Inherits:
-
Object
- Object
- Kaui::Analytics
- Defined in:
- app/models/kaui/analytics.rb
Class Method Summary collapse
- .accounts_over_time ⇒ Object
-
.running_total(per_day) ⇒ Object
The analytics API returns the number of accounts created per day but we want to display a running total.
- .subscriptions_over_time(product_type, slug) ⇒ Object
Class Method Details
.accounts_over_time ⇒ Object
3 4 5 |
# File 'app/models/kaui/analytics.rb', line 3 def self.accounts_over_time running_total(Kaui::KillbillHelper.get_accounts_created_over_time) end |
.running_total(per_day) ⇒ Object
The analytics API returns the number of accounts created per day but we want to display a running total
12 13 14 15 16 17 18 |
# File 'app/models/kaui/analytics.rb', line 12 def self.running_total(per_day) total = [] per_day.values.each_with_index do |value, idx| total << value + (idx == 0 ? 0 : total[idx - 1]) end Kaui::TimeSeriesData.new(:dates => per_day.dates, :values => total) end |
.subscriptions_over_time(product_type, slug) ⇒ Object
7 8 9 |
# File 'app/models/kaui/analytics.rb', line 7 def self.subscriptions_over_time(product_type, slug) running_total(Kaui::KillbillHelper.get_subscriptions_created_over_time(product_type, slug)) end |