34 lines
1.0 KiB
Ruby
34 lines
1.0 KiB
Ruby
module EventNewsMod
|
|
module Migrate
|
|
def self.call
|
|
puts ['event news migrate start']
|
|
gem_root = EventNewsMod::Engine.root
|
|
require File.join(gem_root, 'app/models/event_news_setting')
|
|
require File.join(gem_root, 'app/models/event_news')
|
|
require File.join(gem_root, 'app/models/event_news_feed')
|
|
require File.join(gem_root, 'app/models/event_news_feed_cache')
|
|
|
|
setting = EventNewsSetting.first
|
|
|
|
if !setting.migrate_flag.include?("v1")
|
|
EventNews.all.pluck(:id, :title).each do |id, title_translations|
|
|
if title_translations.nil?
|
|
next
|
|
end
|
|
EventNews.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
|
|
|
|
EventNewsFeedCache.regenerate_all
|
|
|
|
puts ['event news migrate end']
|
|
end
|
|
end
|
|
end |