Commit 92dd57ad5100818469052866d1cca29e6e101adf
1 parent
e6ca0a59
Exists in
master
and in
1 other branch
add support for voter_map with just photocracy or aoi votes
Showing
3 changed files
with
28 additions
and
0 deletions
Show diff stats
app/controllers/questions_controller.rb
@@ -167,6 +167,28 @@ class QuestionsController < InheritedResources::Base | @@ -167,6 +167,28 @@ class QuestionsController < InheritedResources::Base | ||
167 | visitor_id_hash[visitor.thevi] = visitor.the_votes_count | 167 | visitor_id_hash[visitor.thevi] = visitor.the_votes_count |
168 | visitor_id_hash[visitor.thevi] = visitor.the_votes_count | 168 | visitor_id_hash[visitor.thevi] = visitor.the_votes_count |
169 | end | 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 | elsif scope == "creators" | 192 | elsif scope == "creators" |
171 | 193 | ||
172 | questions_created_by_visitor_id = Question.all(:select => 'visitors.identifier as thevi, count(*) as questions_count', | 194 | questions_created_by_visitor_id = Question.all(:select => 'visitors.identifier as thevi, count(*) as questions_count', |
config/environments/development.rb
config/environments/production.rb
@@ -21,3 +21,6 @@ config.gem "rubaidh-google_analytics", | @@ -21,3 +21,6 @@ config.gem "rubaidh-google_analytics", | ||
21 | :lib => "rubaidh/google_analytics", | 21 | :lib => "rubaidh/google_analytics", |
22 | :version => "1.1.4", | 22 | :version => "1.1.4", |
23 | :source => "http://gems.github.com" | 23 | :source => "http://gems.github.com" |
24 | + | ||
25 | +PHOTOCRACY_SITE_ID = 8 | ||
26 | +ALLOURIDEAS_SITE_ID = 1 |