Commit 92dd57ad5100818469052866d1cca29e6e101adf

Authored by Luke Baker
1 parent e6ca0a59

add support for voter_map with just photocracy or aoi votes

app/controllers/questions_controller.rb
... ... @@ -167,6 +167,28 @@ class QuestionsController < InheritedResources::Base
167 167 visitor_id_hash[visitor.thevi] = visitor.the_votes_count
168 168 visitor_id_hash[visitor.thevi] = visitor.the_votes_count
169 169 end
  170 + elsif scope == "all_photocracy_votes"
  171 +
  172 + votes_by_visitor_id= Vote.all(:select => 'visitors.identifier as thevi, count(*) as the_votes_count',
  173 + :joins => :voter,
  174 + :conditions => { :visitors => { :site_id => PHOTOCRACY_SITE_ID }},
  175 + :group => "voter_id")
  176 + visitor_id_hash = {}
  177 + votes_by_visitor_id.each do |visitor|
  178 + visitor_id_hash[visitor.thevi] = visitor.the_votes_count
  179 + visitor_id_hash[visitor.thevi] = visitor.the_votes_count
  180 + end
  181 + elsif scope == "all_aoi_votes"
  182 +
  183 + votes_by_visitor_id= Vote.all(:select => 'visitors.identifier as thevi, count(*) as the_votes_count',
  184 + :joins => :voter,
  185 + :conditions => { :visitors => { :site_id => ALLOURIDEAS_SITE_ID }},
  186 + :group => "voter_id")
  187 + visitor_id_hash = {}
  188 + votes_by_visitor_id.each do |visitor|
  189 + visitor_id_hash[visitor.thevi] = visitor.the_votes_count
  190 + visitor_id_hash[visitor.thevi] = visitor.the_votes_count
  191 + end
170 192 elsif scope == "creators"
171 193  
172 194 questions_created_by_visitor_id = Question.all(:select => 'visitors.identifier as thevi, count(*) as questions_count',
... ...
config/environments/development.rb
... ... @@ -20,3 +20,6 @@ HOST = 'localhost'
20 20  
21 21 config.gem 'mysql',
22 22 :version => '2.8.1'
  23 +
  24 +PHOTOCRACY_SITE_ID = 9
  25 +ALLOURIDEAS_SITE_ID = 13
... ...
config/environments/production.rb
... ... @@ -21,3 +21,6 @@ config.gem "rubaidh-google_analytics",
21 21 :lib => "rubaidh/google_analytics",
22 22 :version => "1.1.4",
23 23 :source => "http://gems.github.com"
  24 +
  25 +PHOTOCRACY_SITE_ID = 8
  26 +ALLOURIDEAS_SITE_ID = 1
... ...