Class: AdminData::AnalyticsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/admin_data/analytics_controller.rb

Instance Attribute Summary

Attributes inherited from ApplicationController

#klass

Instance Method Summary collapse

Instance Method Details

#dailyObject



13
14
15
16
17
18
19
20
# File 'app/controllers/admin_data/analytics_controller.rb', line 13

def daily
  @chart_title = "#{@klass.name} records created in the last 30 days"

  a = AdminData::Analytics.daily_report(@klass, Time.now)
  @chart_data_s = a.map {|e| e.last }.join(', ')
  @chart_data_x_axis = a.map {|e| e.first}.join(', ')
  render :action => 'index'
end

#monthlyObject



22
23
24
25
26
27
28
# File 'app/controllers/admin_data/analytics_controller.rb', line 22

def monthly
  @chart_title = "#{@klass.name} rercords created last year"
  a = AdminData::Analytics.monthly_report(@klass, Time.now)
  @chart_data_s = a.map {|e| e.last }.join(', ')
  @chart_data_x_axis = a.map {|e| e.first}.join(', ')
  render :action => 'index'
end

#render_no_created_atObject



9
10
11
# File 'app/controllers/admin_data/analytics_controller.rb', line 9

def render_no_created_at
  render :text => "Model #{@klass} does not have created_at column"
end

#set_ivarsObject



30
31
32
33
34
35
# File 'app/controllers/admin_data/analytics_controller.rb', line 30

def set_ivars
  @chart_width = 950
  @chart_height = 400
  @chart_h_axis_title = ''
  @chart_legend_name = 'Created'
end