Commit 45c506bae0a064fbbbb0ad90bf8a72e7483beaab
1 parent
8b114f1a
Exists in
master
and in
1 other branch
Minor changes to test_api rake task
Showing
2 changed files
with
9 additions
and
7 deletions
Show diff stats
app/models/vote.rb
... | ... | @@ -9,4 +9,5 @@ class Vote < ActiveRecord::Base |
9 | 9 | named_scope :recent, lambda { |*args| {:conditions => ["created_at > ?", (args.first || Date.today.beginning_of_day)]} } |
10 | 10 | named_scope :with_question, lambda { |*args| {:conditions => {:question_id => args.first }} } |
11 | 11 | named_scope :with_voter_ids, lambda { |*args| {:conditions => {:voter_id=> args.first }} } |
12 | + named_scope :active, :include => :choice, :conditions => { 'choices.active' => true } | |
12 | 13 | end | ... | ... |
lib/tasks/test_api.rake
... | ... | @@ -50,8 +50,8 @@ namespace :test_api do |
50 | 50 | error_bool = true |
51 | 51 | end |
52 | 52 | |
53 | - wins_by_choice_id = question.votes.count(:group => :choice_id) | |
54 | - losses_by_choice_id= question.votes.count(:conditions => "loser_choice_id IS NOT NULL", :group => :loser_choice_id) | |
53 | + wins_by_choice_id = question.votes.active.count(:group => :choice_id) | |
54 | + losses_by_choice_id= question.votes.active.count(:conditions => "loser_choice_id IS NOT NULL", :group => :loser_choice_id) | |
55 | 55 | |
56 | 56 | #Rails returns an ordered hash, which doesn't allow for blocks to change merging logic. |
57 | 57 | #A little hack to create a normal hash |
... | ... | @@ -89,11 +89,12 @@ namespace :test_api do |
89 | 89 | |
90 | 90 | success_msg = "Conducted the following tests on API data and found no inconsistencies.\n" + |
91 | 91 | "For each of the #{questions.length} questions in the database: \n" + |
92 | - " 2 x Total Wins = Total Votes " + | |
93 | - " Total Votes (wins + losses) is Even" + | |
94 | - " Total Votes (wins + losses) = 2 x the number of vote objects that belong to the question" + | |
95 | - " Total generated prompts on left = Total generated prompts on right" + | |
96 | - " Each choice has appeared n times, where n falls within 6 stddevs of the mean number of appearances for a question" | |
92 | + " 2 x Total Wins = Total Votes\n" + | |
93 | + " Total Votes (wins + losses) is Even\n" + | |
94 | + " Total Votes (wins + losses) = 2 x the number of vote objects that belong to the question\n" + | |
95 | + " Total generated prompts on left = Total generated prompts on right\n" + | |
96 | + " Each choice has appeared n times, where n falls within 6 stddevs of the mean number of appearances for a question\n" + | |
97 | + " Note: this applies only to seed choices (not user submitted) and choices currently marked active\n" | |
97 | 98 | |
98 | 99 | print success_msg |
99 | 100 | ... | ... |