FIX: Push category hashtag slug match to top (#19174)

When searching for categories it is possible for
a child category to have a slug that matches the term
exactly, but will not be found by .lookup since we
don't return these categories unless the ref matches
parent:child.

Introduces a search_sort method to each hashtag data
source so they can provide their custom sort logic of
results, in category's case putting all matching slugs
to the top regardless of parent/child relationship
then sorting by text.
This commit is contained in:
Martin Brennan
2022-11-25 15:28:49 +10:00
committed by GitHub
parent 5b6604f5a7
commit cad2fe6089
5 changed files with 58 additions and 6 deletions

View File

@ -40,4 +40,8 @@ class Chat::ChatChannelHashtagDataSource
[]
end
end
def self.search_sort(search_results, _)
search_results.sort_by { |result| result.text.downcase }
end
end