module Referrer::Statistics

Public Class Methods

sources_markup(from, to) click to toggle source
# 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) click to toggle source
# 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