Commit 3105fb29afb55ad9dd58f571d80da02d45a59561
1 parent
e9e218d6
Exists in
master
and in
1 other branch
more performance optimization ... no need for some of these joins
Showing
1 changed file
with
4 additions
and
4 deletions
Show diff stats
app/models/visitor.rb
| ... | ... | @@ -14,16 +14,16 @@ class Visitor < ActiveRecord::Base |
| 14 | 14 | end |
| 15 | 15 | |
| 16 | 16 | def vote_for!(prompt, ordinality) |
| 17 | - question_vote = votes.create!(:voteable => prompt.question) | |
| 18 | - logger.info "Visitor: #{self.inspect} voted for Question: #{prompt.question.inspect}" | |
| 17 | + question_vote = votes.create!(:voteable_id => prompt.question_id, :voteable_type => "Question") | |
| 18 | + logger.info "Visitor: #{self.inspect} voted for Question: #{prompt.question_id}" | |
| 19 | 19 | |
| 20 | 20 | |
| 21 | 21 | choices = prompt.choices |
| 22 | 22 | choice = choices[ordinality] #we need to guarantee that the choices are in the right order (by position) |
| 23 | 23 | prompt_vote = votes.create!(:voteable => prompt) |
| 24 | 24 | logger.info "Visitor: voted for Prompt: #{prompt.id.to_s}" |
| 25 | - @click = Click.new(:what_was_clicked => "on the API level, inside visitor#vote_for! with prompt id #{prompt.id}, ordinality #{ordinality.to_s}, choice: #{choice.item.data} (id: #{choice.id})") | |
| 26 | - @click.save! | |
| 25 | + # @click = Click.new(:what_was_clicked => "on the API level, inside visitor#vote_for! with prompt id #{prompt.id}, ordinality #{ordinality.to_s}, choice: #{choice.item.data} (id: #{choice.id})") | |
| 26 | + # @click.save! | |
| 27 | 27 | |
| 28 | 28 | choice_vote = votes.create!(:voteable => choice) |
| 29 | 29 | # logger.info "Visitor: voted for Prompt: #{prompt.id.to_s} for choice #{choice.item.data}" | ... | ... |