post.rb: handle automatic *_(cosplay) tags in TagImplication.

This commit is contained in:
evazion
2017-03-23 02:48:03 -05:00
parent 0793beded9
commit 4fde2a26fb
2 changed files with 7 additions and 4 deletions

View File

@@ -636,6 +636,7 @@ class Post < ActiveRecord::Base
normalized_tags = %w(tagme) if normalized_tags.empty?
normalized_tags = TagAlias.to_aliased(normalized_tags)
normalized_tags = add_automatic_tags(normalized_tags)
normalized_tags = normalized_tags + TagImplication.automatic_tags_for(normalized_tags)
normalized_tags = TagImplication.with_descendants(normalized_tags)
normalized_tags = normalized_tags.compact
normalized_tags.sort!
@@ -705,10 +706,6 @@ class Post < ActiveRecord::Base
tags << "ugoira"
end
characters = tags.grep(/\A(.+)_\(cosplay\)\Z/) { $1 }
tags += characters
tags << "cosplay" if characters.present?
return tags
end

View File

@@ -32,6 +32,12 @@ class TagImplication < ActiveRecord::Base
def with_descendants(names)
(names + where("antecedent_name in (?) and status in (?)", names, ["active", "processing"]).map(&:descendant_names_array)).flatten.uniq
end
def automatic_tags_for(names)
tags = names.grep(/\A(.+)_\(cosplay\)\Z/) { $1 }
tags << "cosplay" if tags.present?
tags.uniq
end
end
def descendants