diff --git a/app/models/post.rb b/app/models/post.rb index cb14a1792..d8053308a 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -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 diff --git a/app/models/tag_implication.rb b/app/models/tag_implication.rb index 96d2a58b3..cae1ff91b 100644 --- a/app/models/tag_implication.rb +++ b/app/models/tag_implication.rb @@ -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