Commit 81eff1aa authored by Michael Rose's avatar Michael Rose

story: update: add batch fixit method for json encoding 2

parent 5768db34
......@@ -15,13 +15,15 @@
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}"
StoryUpdate.all.find_in_batches(start: 2300000, batch_size: 20) do |updates|
updates.each 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
......
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