implications: refactor calculation of implied tags.
Refactor to use a recursive CTE to calculate implied tags in SQL, rather than storing them in a descendant_names field. This avoids the complexity of keeping the stored field up to date. It's also more flexible, since it allows us to find both descendant tags (tags that imply a given tag) as well as ancestor tags (tags that are implied by a given tag).
This commit is contained in:
@@ -643,7 +643,7 @@ class Post < ApplicationRecord
|
||||
normalized_tags = remove_invalid_tags(normalized_tags)
|
||||
normalized_tags = Tag.convert_cosplay_tags(normalized_tags)
|
||||
normalized_tags += Tag.create_for_list(TagImplication.automatic_tags_for(normalized_tags))
|
||||
normalized_tags = TagImplication.with_descendants(normalized_tags)
|
||||
normalized_tags += TagImplication.tags_implied_by(normalized_tags).map(&:name)
|
||||
normalized_tags = normalized_tags.compact.uniq.sort
|
||||
normalized_tags = Tag.create_for_list(normalized_tags)
|
||||
set_tag_string(normalized_tags.join(" "))
|
||||
|
||||
Reference in New Issue
Block a user