Module: HowAreWeDoing::Controllers::ReportsHelpers

Included in:
ReportsController
Defined in:
lib/how_are_we_doing/controllers/reports_helpers.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
9
# File 'lib/how_are_we_doing/controllers/reports_helpers.rb', line 4

def self.included(base)
  base.respond_to :html, :json, :xml, :js
  base.before_filter :set_dates, :only => :index
  base.before_filter :set_graph_type, :only => :index
  base.before_filter :set_analyticals, :only => :index
end

Instance Method Details

#indexObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/how_are_we_doing/controllers/reports_helpers.rb', line 11

def index
  respond_to do |format|
    format.html
    format.json do
      render :json => { 
        :metrics => {
          :totals => params[:exclude_totals] ? {} : {
            :data => Total.send("json_data_for_#{params[:graph_type]}",params),
            :label => "Totals",
            :color => 0,
            :ticks => Total.send("json_labels_for_#{params[:graph_type]}",params)
          },
          :prints => params[:exclude_prints] ? {} : {
            :data => Print.send("json_data_for_#{params[:graph_type]}",params),
            :label => "Prints",
            :color => 1,
            :ticks => Print.send("json_labels_for_#{params[:graph_type]}",params)
          },
          :views => params[:exclude_views] ? {} : {
            :data => View.send("json_data_for_#{params[:graph_type]}",params),
            :label => "Views",
            :color => 2,
            :ticks => View.send("json_labels_for_#{params[:graph_type]}",params)
          },
          :shares => params[:exclude_shares] ? {} : {
            :data => Share.send("json_data_for_#{params[:graph_type]}",params),
            :label => "Shares",
            :color => 3,
            :ticks => Share.send("json_labels_for_#{params[:graph_type]}",params)
          }
        },
        :format_options => format_options
      }
    end
  end
end