Commit e976c0e7ac5192e60619d2a6159f01422e55d1de
1 parent
e691b72d
Exists in
master
and in
1 other branch
update answered_appearances
only examine valid votes and skips when looking at answered appearances
Showing
1 changed file
with
7 additions
and
1 deletions
Show diff stats
lib/tasks/test_api.rake
... | ... | @@ -669,7 +669,13 @@ namespace :test_api do |
669 | 669 | def answered_appearances_equals_votes_and_skips(question) |
670 | 670 | error_message = "" |
671 | 671 | success_message = "All vote and skip objects have an associated appearance object" |
672 | - total_answered_appearances = Appearance.count(:conditions => ['answerable_id IS NOT NULL AND question_id = ?', question.id]) | |
672 | + skip_appearances_count = Appearance.count( | |
673 | + :conditions => ["skips.valid_record = 1 and appearances.question_id = ? AND answerable_id IS NOT NULL AND answerable_type = 'Skip'", question.id], | |
674 | + :joins => "LEFT JOIN skips ON (skips.id = appearances.answerable_id)") | |
675 | + vote_appearances_count = Appearance.count( | |
676 | + :conditions => ["votes.valid_record = 1 and appearances.question_id = ? AND answerable_id IS NOT NULL and answerable_type = 'Vote'", question.id], | |
677 | + :joins => "LEFT JOIN votes ON (votes.id = appearances.answerable_id)") | |
678 | + total_answered_appearances = skip_appearances_count + vote_appearances_count | |
673 | 679 | total_votes = question.votes.count |
674 | 680 | total_skips = question.skips.count |
675 | 681 | if (total_answered_appearances != total_votes + total_skips) | ... | ... |