Commit 8356a94a668936467a042dbadae3528a94231456

Authored by Dhruv Kapadia
1 parent 780cec07

Change densities to use appearances not votes for calculations

app/models/appearance.rb
@@ -3,5 +3,4 @@ class Appearance < ActiveRecord::Base @@ -3,5 +3,4 @@ class Appearance < ActiveRecord::Base
3 belongs_to :prompt 3 belongs_to :prompt
4 belongs_to :question 4 belongs_to :question
5 has_one :vote 5 has_one :vote
6 -  
7 end 6 end
app/models/prompt.rb
@@ -3,6 +3,7 @@ class Prompt < ActiveRecord::Base @@ -3,6 +3,7 @@ class Prompt < ActiveRecord::Base
3 3
4 has_many :skips 4 has_many :skips
5 has_many :votes 5 has_many :votes
  6 + has_many :appearances
6 7
7 8
8 belongs_to :question, :counter_cache => true 9 belongs_to :question, :counter_cache => true
app/models/question.rb
@@ -255,16 +255,16 @@ class Question < ActiveRecord::Base @@ -255,16 +255,16 @@ class Question < ActiveRecord::Base
255 255
256 the_prompts.each do |p| 256 the_prompts.each do |p|
257 if p.left_choice.user_created == false && p.right_choice.user_created == false 257 if p.left_choice.user_created == false && p.right_choice.user_created == false
258 - seed_seed_sum += p.votes.size 258 + seed_seed_sum += p.appearances.size
259 seed_seed_total +=1 259 seed_seed_total +=1
260 elsif p.left_choice.user_created == false && p.right_choice.user_created == true 260 elsif p.left_choice.user_created == false && p.right_choice.user_created == true
261 - seed_nonseed_sum += p.votes.size 261 + seed_nonseed_sum += p.appearances.size
262 seed_nonseed_total +=1 262 seed_nonseed_total +=1
263 elsif p.left_choice.user_created == true && p.right_choice.user_created == false 263 elsif p.left_choice.user_created == true && p.right_choice.user_created == false
264 - nonseed_seed_sum += p.votes.size 264 + nonseed_seed_sum += p.appearances.size
265 nonseed_seed_total +=1 265 nonseed_seed_total +=1
266 elsif p.left_choice.user_created == true && p.right_choice.user_created == true 266 elsif p.left_choice.user_created == true && p.right_choice.user_created == true
267 - nonseed_nonseed_sum += p.votes.size 267 + nonseed_nonseed_sum += p.appearances.size
268 nonseed_nonseed_total +=1 268 nonseed_nonseed_total +=1
269 end 269 end
270 end 270 end
app/models/visitor.rb
@@ -5,6 +5,7 @@ class Visitor < ActiveRecord::Base @@ -5,6 +5,7 @@ class Visitor < ActiveRecord::Base
5 has_many :skips, :class_name => "Skip", :foreign_key => "skipper_id" 5 has_many :skips, :class_name => "Skip", :foreign_key => "skipper_id"
6 has_many :items, :class_name => "Item", :foreign_key => "creator_id" 6 has_many :items, :class_name => "Item", :foreign_key => "creator_id"
7 has_many :clicks 7 has_many :clicks
  8 + has_many :appearances
8 9
9 validates_presence_of :site, :on => :create, :message => "can't be blank" 10 validates_presence_of :site, :on => :create, :message => "can't be blank"
10 # validates_uniqueness_of :identifier, :on => :create, :message => "must be unique", :scope => :site_id 11 # validates_uniqueness_of :identifier, :on => :create, :message => "must be unique", :scope => :site_id