From 92dd57ad5100818469052866d1cca29e6e101adf Mon Sep 17 00:00:00 2001 From: Luke Baker Date: Fri, 4 Mar 2011 12:31:55 -0500 Subject: [PATCH] add support for voter_map with just photocracy or aoi votes --- app/controllers/questions_controller.rb | 22 ++++++++++++++++++++++ config/environments/development.rb | 3 +++ config/environments/production.rb | 3 +++ 3 files changed, 28 insertions(+), 0 deletions(-) diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index 9b455a0..0df3131 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -167,6 +167,28 @@ class QuestionsController < InheritedResources::Base visitor_id_hash[visitor.thevi] = visitor.the_votes_count visitor_id_hash[visitor.thevi] = visitor.the_votes_count end + elsif scope == "all_photocracy_votes" + + votes_by_visitor_id= Vote.all(:select => 'visitors.identifier as thevi, count(*) as the_votes_count', + :joins => :voter, + :conditions => { :visitors => { :site_id => PHOTOCRACY_SITE_ID }}, + :group => "voter_id") + visitor_id_hash = {} + votes_by_visitor_id.each do |visitor| + visitor_id_hash[visitor.thevi] = visitor.the_votes_count + visitor_id_hash[visitor.thevi] = visitor.the_votes_count + end + elsif scope == "all_aoi_votes" + + votes_by_visitor_id= Vote.all(:select => 'visitors.identifier as thevi, count(*) as the_votes_count', + :joins => :voter, + :conditions => { :visitors => { :site_id => ALLOURIDEAS_SITE_ID }}, + :group => "voter_id") + visitor_id_hash = {} + votes_by_visitor_id.each do |visitor| + visitor_id_hash[visitor.thevi] = visitor.the_votes_count + visitor_id_hash[visitor.thevi] = visitor.the_votes_count + end elsif scope == "creators" questions_created_by_visitor_id = Question.all(:select => 'visitors.identifier as thevi, count(*) as questions_count', diff --git a/config/environments/development.rb b/config/environments/development.rb index af514ec..0c39a12 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -20,3 +20,6 @@ HOST = 'localhost' config.gem 'mysql', :version => '2.8.1' + +PHOTOCRACY_SITE_ID = 9 +ALLOURIDEAS_SITE_ID = 13 diff --git a/config/environments/production.rb b/config/environments/production.rb index 6efa085..bb76da2 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -21,3 +21,6 @@ config.gem "rubaidh-google_analytics", :lib => "rubaidh/google_analytics", :version => "1.1.4", :source => "http://gems.github.com" + +PHOTOCRACY_SITE_ID = 8 +ALLOURIDEAS_SITE_ID = 1 -- libgit2 0.21.2