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:
evazion
2017-11-20 12:13:28 -06:00
parent 05dea309b2
commit 7034a96048
2 changed files with 24 additions and 0 deletions

View 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