Sha256: c611432bb2fb1820407b36298443b325d9a39fd948469a7f315d09e6ee71de42
Contents?: true
Size: 1.98 KB
Versions: 1
Compression:
Stored size: 1.98 KB
Contents
class ReportsController < ApplicationController respond_to :html, :json, :xml, :js before_filter :set_dates, :only => :index def index respond_to do |format| format.html format.json do render :json => { :metrics => { :totals => params[:exclude_totals] ? {} : { :data => Total.json_data_for_chart(params[:start_date],params[:end_date]), :label => "Totals", :color => 0, :ticks => Total.json_labels_for_chart(params[:start_date],params[:end_date]) }, :prints => params[:exclude_prints] ? {} : { :data => Print.json_data_for_chart(params[:start_date],params[:end_date]), :label => "Prints", :color => 1, :ticks => Print.json_labels_for_chart(params[:start_date],params[:end_date]) }, :views => params[:exclude_views] ? {} : { :data => View.json_data_for_chart(params[:start_date],params[:end_date]), :label => "Views", :color => 2, :ticks => View.json_labels_for_chart(params[:start_date],params[:end_date]) }, :shares => params[:exclude_shares] ? {} : { :data => Share.json_data_for_chart(params[:start_date],params[:end_date]), :label => "Shares", :color => 3, :ticks => Share.json_labels_for_chart(params[:start_date],params[:end_date]) } }, :format_options => { :xaxis => { :max => params[:end_date].to_time.to_i, :min => params[:start_date].to_time.to_i } } } end end end protected def set_dates params[:start_date] ||= (Date.today - 1.month) params[:end_date] ||= (Date.today + 1.day)#Time.now.end_of_day.to_date params[:start_date] = Date.parse(params[:start_date].to_s) params[:end_date] = Date.parse(params[:end_date].to_s) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
how_are_we_doing-0.0.4 | app/controllers/reports_controller.rb |