Class: ActiveAnalytics::ReferrersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/active_analytics/referrers_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



7
8
9
10
11
# File 'app/controllers/active_analytics/referrers_controller.rb', line 7

def index
  @referrers = current_views_per_days.top(100).group_by_referrer_site
  @histogram = Histogram.new(current_views_per_days.order_by_date.group_by_date, from_date, to_date)
  @previous_histogram = Histogram.new(previous_views_per_days.order_by_date.group_by_date, previous_from_date, previous_to_date)
end

#showObject



13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/active_analytics/referrers_controller.rb', line 13

def show
  referrer_host, referrer_path = params[:referrer].split("/", 2)
  scope = current_views_per_days.where(referrer_host: referrer_host)
  scope = scope.where(referrer_path: "/" + referrer_path) if referrer_path.present?
  previous_scope = previous_views_per_days.where(referrer_host: params[:referrer])
  @histogram = Histogram.new(scope.order_by_date.group_by_date, from_date, to_date)
  @previous_histogram = Histogram.new(previous_scope.order_by_date.group_by_date, previous_from_date, previous_to_date)
  @previous_pages = scope.top(100).group_by_referrer_page
  @next_pages = scope.top(100).group_by_page
end