Commit fd8191263fdad16010eaafeac6bc41bf2dc189f0
1 parent
8fd2c40f
Exists in
master
and in
1 other branch
Changes to support charts on AOI
Showing
2 changed files
with
15 additions
and
1 deletions
Show diff stats
app/controllers/questions_controller.rb
... | ... | @@ -98,6 +98,20 @@ class QuestionsController < InheritedResources::Base |
98 | 98 | end |
99 | 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 | 115 | protected |
102 | 116 | def export_votes |
103 | 117 | @question = Question.find(params[:id]) | ... | ... |
config/routes.rb
1 | 1 | ActionController::Routing::Routes.draw do |map| |
2 | 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 | 4 | question.resources :items |
5 | 5 | question.resources :prompts, :member => {:vote_left => :post, :vote_right => :post, :skip => :post, :vote => :post}, |
6 | 6 | :collection => {:single => :get, :index => :get} | ... | ... |