Purge invalid gentags from tags table (#3390).
Purges gentags with invalid names from the tags table. Addresses #3390 (Searching certain metatags results in an empty paginator) by removing metatags from the tags table.
This commit is contained in:
20
script/fixes/051_purge_invalid_tags.rb
Executable file
20
script/fixes/051_purge_invalid_tags.rb
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment'))
|
||||
|
||||
CurrentUser.user = User.system
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
|
||||
Tag.transaction do
|
||||
empty_gentags = Tag.empty.where(category: Tag.categories.general)
|
||||
total = empty_gentags.count
|
||||
|
||||
empty_gentags.find_each.with_index do |tag, i|
|
||||
STDERR.puts %{validating "#{tag.name}" (#{i}/#{total})} if i % 1000 == 0
|
||||
|
||||
if tag.invalid?(:create)
|
||||
# puts ({ name: tag.name, id: tag.id }).to_json
|
||||
tag.delete
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user