Module: Analytics::Formatters
- Included in:
- Analytics
- Defined in:
- lib/analytics_logger/analytics/formatters.rb
Overview
The formatters for the Analytics class (may eventually split this out to Analytics::Formatters and Analytics::Formatters::HighCharts)
Instance Method Summary collapse
- #date_array_for_highcharts(events) ⇒ Object
- #month_array_for_highcharts(events) ⇒ Object
- #total_data_array_for_highcharts(events) ⇒ Object
- #total_month_data_array_for_highcharts(events) ⇒ Object
Instance Method Details
#date_array_for_highcharts(events) ⇒ Object
7 8 9 |
# File 'lib/analytics_logger/analytics/formatters.rb', line 7 def date_array_for_highcharts(events) events.map {|ae| "'#{ae.created_at.strftime("%m/%d/%y")}'" }.uniq.sort end |
#month_array_for_highcharts(events) ⇒ Object
11 12 13 |
# File 'lib/analytics_logger/analytics/formatters.rb', line 11 def month_array_for_highcharts(events) events.map {|ae| "'#{ae.created_at.strftime("%b %Y")}'" }.uniq end |
#total_data_array_for_highcharts(events) ⇒ Object
15 16 17 18 19 |
# File 'lib/analytics_logger/analytics/formatters.rb', line 15 def total_data_array_for_highcharts(events) dates = events.map {|ae| "'#{ae.created_at.strftime("%m/%d/%y")}'" }.sort keys = dates.uniq keys.map {|key| dates.count(key) } end |
#total_month_data_array_for_highcharts(events) ⇒ Object
21 22 23 24 25 |
# File 'lib/analytics_logger/analytics/formatters.rb', line 21 def total_month_data_array_for_highcharts(events) dates = events.map {|ae| "'#{ae.created_at.strftime("%b %Y")}'" } keys = dates.uniq keys.map {|key| dates.count(key) } end |