Class: Concen::TrafficsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/concen/traffics_controller.rb

Instance Method Summary collapse

Instance Method Details

#pagesObject



29
30
31
32
33
34
# File 'app/controllers/concen/traffics_controller.rb', line 29

def pages
  @pages_stats = Visit::Page.aggregate_count_by_url(:limit => 6)
  respond_to do |format|
    format.html { render :partial => "concen/traffics/pages" }
  end
end

#referralsObject



36
37
38
39
40
41
# File 'app/controllers/concen/traffics_controller.rb', line 36

def referrals
  @referrals_stats = Visit::Referral.aggregate_count_by_domain(:limit => 6)
  respond_to do |format|
    format.html { render :partial => "concen/traffics/referrals" }
  end
end

#showObject

Supports OS X and Linux, require top command.

@current_month_visits = Statistic.visits_for_current :month

Real time visits Historical statistics Month: visits



12
13
14
# File 'app/controllers/concen/traffics_controller.rb', line 12

def show
  @page_title = "Traffic"
end

#visits_countsObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/concen/traffics_controller.rb', line 16

def visits_counts
  if @stats = Visit::Page.aggregate_count_by_time(:hour => params[:hour], :precision => "millisecond")
    # Readjust timestamp because flot graph doesn't handle time zone.
    @stats.map! do |s|
      time = Time.zone.at s[0]/1000
      [(time.utc.to_i + time.utc_offset)*1000, s[1]]
    end
  end
  respond_to do |format|
    format.json { render :json => @stats }
  end
end