diff --git a/Rakefile b/Rakefile index 6a8f06a8..96f01872 100644 --- a/Rakefile +++ b/Rakefile @@ -184,6 +184,24 @@ task :primenewstriperunonlyonce => [:environment] do end +desc 'dedupe tags' +task :dedupetags => [:environment] do + Tag.all.each do |tag| + begin + tag.reload + rescue Sequel::Error => e + next if e.message =~ /Record not found/ + end + + matching_tags = Tag.exclude(id: tag.id).where(name: tag.name).all + + matching_tags.each do |matching_tag| + DB[:sites_tags].where(tag_id: matching_tag.id).update(tag_id: tag.id) + matching_tag.delete + end + end +end + desc 'Clean tags' task :cleantags => [:environment] do @@ -208,21 +226,6 @@ task :cleantags => [:environment] do end end - Tag.all.each do |tag| - begin - tag.reload - rescue Sequel::Error => e - next if e.message =~ /Record not found/ - end - - matching_tags = Tag.exclude(id: tag.id).where(name: tag.name).all - - matching_tags.each do |matching_tag| - DB[:sites_tags].where(tag_id: matching_tag.id).update(tag_id: tag.id) - matching_tag.delete - end - end - Tag.where(name: 'porn').first.update is_nsfw: true end