tags/index: don't show aliases when search matches primary tag.

When searching e.g. "*mask*", don't show "surgical_mask <- medical_mask"
because "*mask*" already matches the primary tag.
This commit is contained in:
evazion
2020-03-03 03:34:34 -06:00
parent 0890963187
commit c0376ebb51
2 changed files with 9 additions and 3 deletions

View File

@@ -3,4 +3,12 @@ module TagsHelper
return nil if tag.blank?
"tag-type-#{tag.category}"
end
def tag_alias_for_pattern(tag, pattern)
return nil if pattern.blank?
tag.consequent_aliases.find do |tag_alias|
!tag.name.ilike?(pattern) && tag_alias.antecedent_name.ilike?(pattern)
end
end
end