Commit fd8191263fdad16010eaafeac6bc41bf2dc189f0

Authored by Dhruv Kapadia
1 parent 8fd2c40f

Changes to support charts on AOI

app/controllers/questions_controller.rb
@@ -98,6 +98,20 @@ class QuestionsController < InheritedResources::Base @@ -98,6 +98,20 @@ class QuestionsController < InheritedResources::Base
98 end 98 end
99 end 99 end
100 100
  101 + def object_info_totals_by_date
  102 + authenticate
  103 +
  104 + # eventually allow for users to specify type of export through params[:type]
  105 + @question = current_user.questions.find(params[:id])
  106 + hash = Vote.count(:conditions => "question_id = #{@question.id}", :group => "date(created_at)")
  107 +
  108 + respond_to do |format|
  109 + format.xml { render :xml => hash.to_xml and return}
  110 + end
  111 + end
  112 +
  113 +
  114 +
101 protected 115 protected
102 def export_votes 116 def export_votes
103 @question = Question.find(params[:id]) 117 @question = Question.find(params[:id])
config/routes.rb
1 ActionController::Routing::Routes.draw do |map| 1 ActionController::Routing::Routes.draw do |map|
2 map.resources :clicks 2 map.resources :clicks
3 - map.resources :questions, :member => { :num_votes_by_visitor_id => :get, :export => :post, :set_autoactivate_ideas_from_abroad => :put, :activate => :put, :suspend => :put} do |question| 3 + map.resources :questions, :member => { :object_info_totals_by_date => :get, :num_votes_by_visitor_id => :get, :export => :post, :set_autoactivate_ideas_from_abroad => :put, :activate => :put, :suspend => :put} do |question|
4 question.resources :items 4 question.resources :items
5 question.resources :prompts, :member => {:vote_left => :post, :vote_right => :post, :skip => :post, :vote => :post}, 5 question.resources :prompts, :member => {:vote_left => :post, :vote_right => :post, :skip => :post, :vote => :post},
6 :collection => {:single => :get, :index => :get} 6 :collection => {:single => :get, :index => :get}