fixes
This commit is contained in:
parent
5bb521685f
commit
6f93538e60
|
|
@ -4,14 +4,16 @@
|
|||
# end
|
||||
namespace :video_pro_tasks do
|
||||
desc "Migrate old tags to new tags"
|
||||
task :migrate_tags => :environment do
|
||||
task :migrate_hashtags => :environment do
|
||||
module_app = ModuleApp.find_by_key("video_pro")
|
||||
dataset = {}
|
||||
VideoTag.all.each do |vt|
|
||||
next if vt.title.blank? # Skip if tag name is blank
|
||||
next if vt.video_images.empty? # Skip if no images are associated with the tag
|
||||
puts "Processing tag: #{vt.title}"
|
||||
module_app.reload
|
||||
hashtag = module_app.hashtags.where(name: vt.title).first_or_initialize
|
||||
tag_str = vt.title.gsub(/^#+/, '').downcase.strip
|
||||
hashtag = module_app.hashtags.where(name: tag_str).first_or_initialize
|
||||
hashtag.module_app_ids << module_app.id.to_s unless hashtag.module_app_ids.include?(module_app.id.to_s)
|
||||
puts "New record #{hashtag.new_record?}"
|
||||
hashtag.save if hashtag.new_record?
|
||||
|
|
|
|||
Loading…
Reference in New Issue