Commit a43ab92a804328a83e433db3e0861476ab44e829

Authored by Dhruv Kapadia
1 parent 53182fda

Adding response time and missing response time exp to csv

Showing 1 changed file with 9 additions and 5 deletions   Show diff stats
app/models/question.rb
@@ -378,7 +378,7 @@ class Question < ActiveRecord::Base @@ -378,7 +378,7 @@ class Question < ActiveRecord::Base
378 378
379 headers = ['Vote ID', 'Session ID', 'Question ID','Winner ID', 'Winner Text', 'Loser ID', 'Loser Text', 379 headers = ['Vote ID', 'Session ID', 'Question ID','Winner ID', 'Winner Text', 'Loser ID', 'Loser Text',
380 'Prompt ID', 'Left Choice ID', 'Right Choice ID', 'Created at', 'Updated at', 'Appearance ID', 380 'Prompt ID', 'Left Choice ID', 'Right Choice ID', 'Created at', 'Updated at', 'Appearance ID',
381 - 'Response Time (s)', 'Session Identifier'] 381 + 'Response Time (s)', 'Missing Response Time Explanation', 'Session Identifier']
382 382
383 when 'ideas' 383 when 'ideas'
384 outfile = "ideamarketplace_#{self.id}_ideas.csv" 384 outfile = "ideamarketplace_#{self.id}_ideas.csv"
@@ -389,7 +389,7 @@ class Question < ActiveRecord::Base @@ -389,7 +389,7 @@ class Question < ActiveRecord::Base
389 outfile = "ideamarketplace_#{self.id}_non_votes.csv" 389 outfile = "ideamarketplace_#{self.id}_non_votes.csv"
390 headers = ['Record Type', 'Record ID', 'Session ID', 'Question ID','Left Choice ID', 'Left Choice Text', 390 headers = ['Record Type', 'Record ID', 'Session ID', 'Question ID','Left Choice ID', 'Left Choice Text',
391 'Right Choice ID', 'Right Choice Text', 'Prompt ID', 'Appearance ID', 'Reason', 391 'Right Choice ID', 'Right Choice Text', 'Prompt ID', 'Appearance ID', 'Reason',
392 - 'Created at', 'Updated at', 'Response Time (s)', 'Session Identifier'] 392 + 'Created at', 'Updated at', 'Response Time (s)', 'Missing Response Time Explanation', 'Session Identifier']
393 else 393 else
394 raise "Unsupported export type: #{type}" 394 raise "Unsupported export type: #{type}"
395 end 395 end
@@ -411,9 +411,11 @@ class Question < ActiveRecord::Base @@ -411,9 +411,11 @@ class Question < ActiveRecord::Base
411 left_id = v.prompt.nil? ? "" : v.prompt.left_choice_id 411 left_id = v.prompt.nil? ? "" : v.prompt.left_choice_id
412 right_id = v.prompt.nil? ? "" : v.prompt.right_choice_id 412 right_id = v.prompt.nil? ? "" : v.prompt.right_choice_id
413 413
  414 + time_viewed = v.time_viewed.nil? ? "NA": v.time_viewed.to_f / 1000.0
  415 +
414 csv << [ v.id, v.voter_id, v.question_id, v.choice_id, "'#{v.choice.data.strip}'", v.loser_choice_id, loser_data, 416 csv << [ v.id, v.voter_id, v.question_id, v.choice_id, "'#{v.choice.data.strip}'", v.loser_choice_id, loser_data,
415 v.prompt_id, left_id, right_id, v.created_at, v.updated_at, v.appearance_id, 417 v.prompt_id, left_id, right_id, v.created_at, v.updated_at, v.appearance_id,
416 - v.time_viewed.to_f / 1000.0 , v.voter.identifier] 418 + time_viewed, v.missing_response_time_exp , v.voter.identifier]
417 end 419 end
418 420
419 when 'ideas' 421 when 'ideas'
@@ -444,15 +446,17 @@ class Question &lt; ActiveRecord::Base @@ -444,15 +446,17 @@ class Question &lt; ActiveRecord::Base
444 prompt = a.prompt 446 prompt = a.prompt
445 csv << [ "Orphaned Appearance", a.id, a.voter_id, a.question_id, a.prompt.left_choice.id, a.prompt.left_choice.data.strip, 447 csv << [ "Orphaned Appearance", a.id, a.voter_id, a.question_id, a.prompt.left_choice.id, a.prompt.left_choice.data.strip,
446 a.prompt.right_choice.id, a.prompt.right_choice.data.strip, a.prompt_id, 'N/A', 'N/A', 448 a.prompt.right_choice.id, a.prompt.right_choice.data.strip, a.prompt_id, 'N/A', 'N/A',
447 - a.created_at, a.updated_at, 'N/A', a.voter.identifier] 449 + a.created_at, a.updated_at, 'N/A', '', a.voter.identifier]
448 450
449 else 451 else
  452 +
450 #If this appearance belongs to a skip, show information on the skip instead 453 #If this appearance belongs to a skip, show information on the skip instead
451 s = a.skip 454 s = a.skip
  455 + time_viewed = s.time_viewed.nil? ? "NA": s.time_viewed.to_f / 1000.0
452 prompt = s.prompt 456 prompt = s.prompt
453 csv << [ "Skip", s.id, s.skipper_id, s.question_id, s.prompt.left_choice.id, s.prompt.left_choice.data.strip, 457 csv << [ "Skip", s.id, s.skipper_id, s.question_id, s.prompt.left_choice.id, s.prompt.left_choice.data.strip,
454 s.prompt.right_choice.id, s.prompt.right_choice.data.strip, s.prompt_id, s.appearance_id, s.skip_reason, 458 s.prompt.right_choice.id, s.prompt.right_choice.data.strip, s.prompt_id, s.appearance_id, s.skip_reason,
455 - s.created_at, s.updated_at, s.time_viewed.to_f / 1000.0 , s.skipper.identifier] 459 + s.created_at, s.updated_at, time_viewed , s.missing_response_time_exp, s.skipper.identifier]
456 end 460 end
457 end 461 end
458 end 462 end