33 lines
899 B
Ruby
33 lines
899 B
Ruby
module Curation
|
|
module Migrate
|
|
def self.call
|
|
puts ['curation migrate start']
|
|
gem_root = Curation::Engine.root
|
|
require File.join(gem_root, 'app/models/curation_setting')
|
|
require File.join(gem_root, 'app/models/curation_cache')
|
|
|
|
setting = CurationSetting.first || CurationSetting.create
|
|
|
|
if !setting.migrate_flag.include?("v1")
|
|
CurationPost.all.pluck(:id, :title_translations).each do |id, title_translations|
|
|
if title_translations.nil?
|
|
next
|
|
end
|
|
CurationPost.where(id: id).view.update_many({
|
|
"$set" => {
|
|
title_plain_text: OrbitHelper.get_plain_text_translations(title_translations)
|
|
}
|
|
})
|
|
end
|
|
|
|
setting.migrate_flag << "v1"
|
|
setting.save
|
|
end
|
|
|
|
CurationCache.all.delete
|
|
|
|
puts ['curation migrate end']
|
|
end
|
|
end
|
|
end
|