fixes #3735
This commit is contained in:
@@ -1,3 +1,15 @@
|
||||
class PixivUgoiraFrameData < ApplicationRecord
|
||||
serialize :data
|
||||
before_validation :normalize_data, on: :create
|
||||
|
||||
def normalize_data
|
||||
return if data.nil?
|
||||
|
||||
if data[0]["delay_msec"]
|
||||
self.data = data.map.with_index do |datum, i|
|
||||
filename = "%06d.jpg" % [i + 1]
|
||||
{"delay" => datum["delay_msec"], "file" => filename}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
11
script/fixes/053_normalize_ugoira_data.rb
Normal file
11
script/fixes/053_normalize_ugoira_data.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment'))
|
||||
|
||||
CurrentUser.user = User.system
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
|
||||
PixivUgoiraFrameData.where("data like ?", "\%delay_msec%").find_each do |fd|
|
||||
fd.normalize_data
|
||||
fd.save
|
||||
end
|
||||
Reference in New Issue
Block a user