Add migration task for ad_banner
This commit is contained in:
parent
1d32552b51
commit
cce8f1be9b
|
@ -43,6 +43,10 @@ namespace :new_ui do
|
|||
migrate_ad_images_dates
|
||||
end
|
||||
|
||||
task :migrate_ad_banners => :environment do
|
||||
migrate_ad_banners
|
||||
end
|
||||
|
||||
def migrate_categories(args = nil)
|
||||
if args && args[:app_key] && args[:model_name]
|
||||
migrate_category(args[:app_key], args[:model_name], args[:category_name])
|
||||
|
@ -213,4 +217,19 @@ namespace :new_ui do
|
|||
end
|
||||
end
|
||||
|
||||
def migrate_ad_banners
|
||||
@db ||= Mongoid.database
|
||||
collection_ad_banner = @db['ad_banners']
|
||||
ad_banners = collection_ad_banner.find()
|
||||
ad_banners.each do |ad_banner|
|
||||
ad_banner['timeout'] = ad_banner['transition_msec']/1000 if ad_banner['transition_msec'].present?
|
||||
ad_banner['speed'] = 500 unless ad_banner['speed'].present?
|
||||
ad_banner['width'], ad_banner['height'] = ad_banner['best_size'].gsub('px', '').delete(' ').split('x').map{|d| d.to_i} if ad_banner['best_size'].present?
|
||||
ad_banner['ad_fx'] = (AdBanner::FX_TYPES.include?(ad_banner['ad_fx']) ? ad_banner['ad_fx'] : AdBanner::FX_TYPES[0])
|
||||
ad_banner.delete('best_size')
|
||||
ad_banner.delete('transition_msec')
|
||||
collection_ad_banner.save(ad_banner)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Reference in New Issue