post.rb: handle automatic *_(cosplay) tags in TagImplication.
This commit is contained in:
@@ -636,6 +636,7 @@ class Post < ActiveRecord::Base
|
|||||||
normalized_tags = %w(tagme) if normalized_tags.empty?
|
normalized_tags = %w(tagme) if normalized_tags.empty?
|
||||||
normalized_tags = TagAlias.to_aliased(normalized_tags)
|
normalized_tags = TagAlias.to_aliased(normalized_tags)
|
||||||
normalized_tags = add_automatic_tags(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 = TagImplication.with_descendants(normalized_tags)
|
||||||
normalized_tags = normalized_tags.compact
|
normalized_tags = normalized_tags.compact
|
||||||
normalized_tags.sort!
|
normalized_tags.sort!
|
||||||
@@ -705,10 +706,6 @@ class Post < ActiveRecord::Base
|
|||||||
tags << "ugoira"
|
tags << "ugoira"
|
||||||
end
|
end
|
||||||
|
|
||||||
characters = tags.grep(/\A(.+)_\(cosplay\)\Z/) { $1 }
|
|
||||||
tags += characters
|
|
||||||
tags << "cosplay" if characters.present?
|
|
||||||
|
|
||||||
return tags
|
return tags
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,12 @@ class TagImplication < ActiveRecord::Base
|
|||||||
def with_descendants(names)
|
def with_descendants(names)
|
||||||
(names + where("antecedent_name in (?) and status in (?)", names, ["active", "processing"]).map(&:descendant_names_array)).flatten.uniq
|
(names + where("antecedent_name in (?) and status in (?)", names, ["active", "processing"]).map(&:descendant_names_array)).flatten.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def automatic_tags_for(names)
|
||||||
|
tags = names.grep(/\A(.+)_\(cosplay\)\Z/) { $1 }
|
||||||
|
tags << "cosplay" if tags.present?
|
||||||
|
tags.uniq
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def descendants
|
def descendants
|
||||||
|
|||||||
Reference in New Issue
Block a user