Skip to content

Instantly share code, notes, and snippets.

@mark
Created November 29, 2010 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mark/720036 to your computer and use it in GitHub Desktop.
Save mark/720036 to your computer and use it in GitHub Desktop.
# (1) Search through the logs for the responses
# tail -n 1000000 current/log/production.log | grep '"id"=>"<EVALUATION RESPONSE ID GOES HERE>"'
# (2) Copy and paste results into output.txt file in the same directory as this, and then run this file
def print_responses(hsh)
needed = {}
hsh["responses"].keys.sort.each do |k|
v = hsh["responses"][k]
puts "#{k}\t#{ v["value"] }" if v["value"]
needed[k.to_i] = v["value"].to_i if v["value"] && ! v["value"].strip != ""
end
puts "Found #{needed.keys.length} keys"
puts
print "hash = "
puts needed.inspect
puts
end
contents = File.read("output.txt")
lines = contents.split("Parameters: ").map { |txt| eval(txt) }.compact.select { |hsh| hsh["responses"] }
lines.each { |l| print_responses l }
puts
# (3) In console, paste the following method:
def update_evaluation_responses(hash)
hash.each do |qr_id, value|
qr = QuestionResponse / qr_id
qr.value = value
qr.save
end
end
# (4) paste in the hash = {...} line and then call update_evaluation_responses(hash)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment