Commit 5768db34 authored by Michael Rose's avatar Michael Rose

story: update: add batch fixit method for json encoding

parent 8f1a994d
......@@ -14,4 +14,16 @@
#
class StoryUpdate < ActiveRecord::Base
def self.fix_json
StoryUpdate.all.find_in_batches(start: 2300000, batch_size: 20) do |update|
if update.update_contents.starts_with?('"')
begin
update.update_contents = JSON.parse(update.update_contents)
update.save!
rescue => e
puts "Failed to update StoryUpdate(#{update.id}): #{e}"
end
end
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment