Commit 968b95459c88fb9fc8a523105fcf61e4fb354102

Authored by Pius Uzamere
1 parent 2f4bd214

db optimizations

app/models/visitor.rb
... ... @@ -26,11 +26,11 @@ class Visitor < ActiveRecord::Base
26 26 @click.save!
27 27  
28 28 choice_vote = votes.create!(:voteable => choice)
29   - logger.info "Visitor: voted for Prompt: #{prompt.id.to_s} for choice #{choice.item.data}"
30   - choice.save!
31   - choice.score = choice.compute_score
32   - logger.info "Just computed the score for that choice and it's apparently #{choice.score}"
33   - choice.save!
  29 + # logger.info "Visitor: voted for Prompt: #{prompt.id.to_s} for choice #{choice.item.data}"
  30 + # choice.save!
  31 + # choice.score = choice.compute_score
  32 + # logger.info "Just computed the score for that choice and it's apparently #{choice.score}"
  33 + # choice.save!
34 34 logger.info "Saved. That choice's score is still #{choice.score}"
35 35 other_choices = choices - [choice]
36 36 other_choices.each {|c| c.lose! }
... ...
db/migrate/20091219050747_add_index_to_prompts.rb 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +class AddIndexToPrompts < ActiveRecord::Migration
  2 + def self.up
  3 + add_index :prompts, [:left_choice_id, :right_choice_id]
  4 + end
  5 +
  6 + def self.down
  7 + remove_index :prompts, [:left_choice_id, :right_choice_id]
  8 + end
  9 +end
... ...