better error handling in data.rake

pull/1/head
Jared Cosulich 8 years ago
parent ee44c1227c
commit ae5d2ede98

@ -185,7 +185,7 @@ namespace :data do
if school.nil? if school.nil?
next if unknown_schools[school_name] next if unknown_schools[school_name]
puts "DATAMSG: Unable to find school: #{school_name} - #{index}" puts "DATAERROR: Unable to find school: #{school_name} - #{index}"
unknown_schools[school_name] = true unknown_schools[school_name] = true
next next
end end
@ -200,7 +200,7 @@ namespace :data do
name: "Survey Respondent Id: #{respondent_id}" name: "Survey Respondent Id: #{respondent_id}"
) )
rescue rescue
puts "DATAMSG: ERROR AT #{index} - #{district.name} - #{school_name} #{school}: #{respondent_id}" puts "DATAERROR: ERROR AT #{index} - #{district.name} - #{school_name} #{school}: #{respondent_id}"
end end
respondent_map[respondent_id] = recipient.id respondent_map[respondent_id] = recipient.id
end end
@ -221,7 +221,7 @@ namespace :data do
question = Question.find_by_text(key) question = Question.find_by_text(key)
if question.nil? if question.nil?
next if missing_questions[key] next if missing_questions[key]
puts "Unable to find question: #{key}" puts "DATAERROR: Unable to find question: #{key}"
missing_questions[key] = true missing_questions[key] = true
next next
else else
@ -238,7 +238,7 @@ namespace :data do
if answer_index.nil? if answer_index.nil?
next if bad_answers[key] next if bad_answers[key]
puts "Unable to find answer: #{key} = #{value.downcase.strip} - #{question.options.inspect}" puts "DATAERROR: Unable to find answer: #{key} = #{value.downcase.strip} - #{question.options.inspect}"
bad_answers[key] = true bad_answers[key] = true
next next
end end
@ -247,7 +247,12 @@ namespace :data do
end end
responded_at = Date.strptime(row['End Date'], '%m/%d/%Y %H:%M') responded_at = Date.strptime(row['End Date'], '%m/%d/%Y %H:%M')
recipient.attempts.create(question: question, answer_index: answer_index, responded_at: responded_at) begin
recipient.attempts.create(question: question, answer_index: answer_index, responded_at: responded_at)
rescue
puts "DATAERROR: Attempt failed for #{recipient} -> QUESTION: #{question}, ANSWER_INDEX: #{answer_index}, RESPONDED_AT: #{responded_at}"
next
end
end end
end end
end end

Loading…
Cancel
Save