Commit d1ee43f12952334c5f59960ae8bc7844ddb45696
1 parent
706e8359
Exists in
master
and in
1 other branch
update CSV output of non-votes to no longer fail
CSV report of non-votes wasn't updated after the Appearance model was changed from having separate Skip and Vote objects to using Answerable as a polymorphic relationship. This fixes that over-sight.
Showing
2 changed files
with
11 additions
and
9 deletions
Show diff stats
app/models/question.rb
@@ -560,21 +560,21 @@ class Question < ActiveRecord::Base | @@ -560,21 +560,21 @@ class Question < ActiveRecord::Base | ||
560 | end | 560 | end |
561 | when 'non_votes' | 561 | when 'non_votes' |
562 | 562 | ||
563 | - self.appearances.find_each(:include => [:skip, :vote, :voter]) do |a| | 563 | + self.appearances.find_each(:include => [:answerable, :voter]) do |a| |
564 | # we only display skips and orphaned appearances in this csv file | 564 | # we only display skips and orphaned appearances in this csv file |
565 | - next unless a.vote.nil? | 565 | + next if a.answerable.class == Vote |
566 | 566 | ||
567 | - #If no skip and no vote, this is an orphaned appearance | ||
568 | - if a.skip.nil? | ||
569 | - prompt = a.prompt | ||
570 | - csv << [ "Orphaned Appearance", a.id, a.voter_id, a.question_id, a.prompt.left_choice.id, a.prompt.left_choice.data.strip, a.prompt.right_choice.id, a.prompt.right_choice.data.strip, a.prompt_id, 'N/A', 'N/A', a.created_at, a.updated_at, 'N/A', '', a.voter.identifier] | ||
571 | - | ||
572 | - else | 567 | + if a.answerable.class == Skip |
573 | # If this appearance belongs to a skip, show information on the skip instead | 568 | # If this appearance belongs to a skip, show information on the skip instead |
574 | - s = a.skip | 569 | + s = a.answerable |
575 | time_viewed = s.time_viewed.nil? ? "NA": s.time_viewed.to_f / 1000.0 | 570 | time_viewed = s.time_viewed.nil? ? "NA": s.time_viewed.to_f / 1000.0 |
576 | prompt = s.prompt | 571 | prompt = s.prompt |
577 | csv << [ "Skip", s.id, s.skipper_id, s.question_id, s.prompt.left_choice.id, s.prompt.left_choice.data.strip, s.prompt.right_choice.id, s.prompt.right_choice.data.strip, s.prompt_id, s.appearance_id, s.skip_reason, s.created_at, s.updated_at, time_viewed , s.missing_response_time_exp, s.skipper.identifier] | 572 | csv << [ "Skip", s.id, s.skipper_id, s.question_id, s.prompt.left_choice.id, s.prompt.left_choice.data.strip, s.prompt.right_choice.id, s.prompt.right_choice.data.strip, s.prompt_id, s.appearance_id, s.skip_reason, s.created_at, s.updated_at, time_viewed , s.missing_response_time_exp, s.skipper.identifier] |
573 | + | ||
574 | + else | ||
575 | + # If no skip and no vote, this is an orphaned appearance | ||
576 | + prompt = a.prompt | ||
577 | + csv << [ "Orphaned Appearance", a.id, a.voter_id, a.question_id, a.prompt.left_choice.id, a.prompt.left_choice.data.strip, a.prompt.right_choice.id, a.prompt.right_choice.data.strip, a.prompt_id, 'N/A', 'N/A', a.created_at, a.updated_at, 'N/A', '', a.voter.identifier] | ||
578 | end | 578 | end |
579 | end | 579 | end |
580 | end | 580 | end |
spec/models/question_spec.rb
@@ -384,6 +384,8 @@ describe Question do | @@ -384,6 +384,8 @@ describe Question do | ||
384 | rows.first.should include("Record ID") | 384 | rows.first.should include("Record ID") |
385 | rows.first.should include("Record Type") | 385 | rows.first.should include("Record Type") |
386 | rows.first.should_not include("Idea ID") | 386 | rows.first.should_not include("Idea ID") |
387 | + # ensure we have more than just the header row | ||
388 | + rows.length.should be > 1 | ||
387 | File.delete(filename).should_not be_nil | 389 | File.delete(filename).should_not be_nil |
388 | 390 | ||
389 | 391 |