Module: Referrer::Statistics
- Defined in:
- lib/modules/statistics.rb
Class Method Summary collapse
Class Method Details
.sources_markup(from, to) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/modules/statistics.rb', line 4 def sources_markup(from, to) Referrer::Source.where('created_at >= ? AND created_at <= ?', from, to).group_by do |source| source.to_markup.symbolize_keys! end.map do |markup, matches| markup.merge({count: matches.size}) end end |
.tracked_objects_markup(from, to, type: nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/modules/statistics.rb', line 12 def tracked_objects_markup(from, to, type: nil) result = Referrer::SourcesTrackedObject.where('linked_at >= ? AND linked_at <= ?', from, to).includes(:source) result = result.where(trackable_type: type) if type.present? result.map{|item| item.source}.select do |source| source.present? end.group_by do |source| source.to_markup.symbolize_keys! end.map do |markup, matches| markup.merge({count: matches.size}) end end |