From fd8191263fdad16010eaafeac6bc41bf2dc189f0 Mon Sep 17 00:00:00 2001 From: Dhruv Kapadia Date: Wed, 24 Feb 2010 16:07:13 -0500 Subject: [PATCH] Changes to support charts on AOI --- app/controllers/questions_controller.rb | 14 ++++++++++++++ config/routes.rb | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index 7a921e0..b6918fc 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -98,6 +98,20 @@ class QuestionsController < InheritedResources::Base end end + def object_info_totals_by_date + authenticate + + # eventually allow for users to specify type of export through params[:type] + @question = current_user.questions.find(params[:id]) + hash = Vote.count(:conditions => "question_id = #{@question.id}", :group => "date(created_at)") + + respond_to do |format| + format.xml { render :xml => hash.to_xml and return} + end + end + + + protected def export_votes @question = Question.find(params[:id]) diff --git a/config/routes.rb b/config/routes.rb index 9629d3a..abcdab6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,6 @@ ActionController::Routing::Routes.draw do |map| map.resources :clicks - map.resources :questions, :member => { :num_votes_by_visitor_id => :get, :export => :post, :set_autoactivate_ideas_from_abroad => :put, :activate => :put, :suspend => :put} do |question| + 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| question.resources :items question.resources :prompts, :member => {:vote_left => :post, :vote_right => :post, :skip => :post, :vote => :post}, :collection => {:single => :get, :index => :get} -- libgit2 0.21.2