Commit d9a98556e0cc83a6e3a50a08587d09a5397f78a7
1 parent
d99cc225
Exists in
master
and in
1 other branch
spike
Showing
1 changed file
with
6 additions
and
2 deletions
Show diff stats
app/models/choice.rb
... | ... | @@ -19,6 +19,11 @@ class Choice < ActiveRecord::Base |
19 | 19 | def wins_plus_losses |
20 | 20 | #(prompts_on_the_left.collect(&:votes_count).sum + prompts_on_the_right.collect(&:votes_count).sum) |
21 | 21 | Prompt.sum('votes_count', :conditions => "left_choice_id = #{id} OR right_choice_id = #{id}") |
22 | + #wins + losses | |
23 | + end | |
24 | + | |
25 | + def losses | |
26 | + loss_count | |
22 | 27 | end |
23 | 28 | |
24 | 29 | def wins |
... | ... | @@ -37,10 +42,9 @@ class Choice < ActiveRecord::Base |
37 | 42 | return true #so active record will save |
38 | 43 | end |
39 | 44 | |
40 | - | |
41 | 45 | def compute_score |
42 | 46 | if wins_plus_losses == 0 |
43 | - return 0 | |
47 | + raise 'wtfbbq'#return 0 | |
44 | 48 | else |
45 | 49 | (wins.to_f / wins_plus_losses ) * 100 |
46 | 50 | end | ... | ... |