FIX: Show user filter hints when typing @ in search (#13799)

Will show the last 6 seen users as filtering suggestions when typing @ in quick search. (Previously the user suggestion required a character after the @.)

This also adds a default limit of 6 to the user search query, previously the backend was returning 20 results but a maximum of 6 results was being shown anyway.
This commit is contained in:
Penar Musaraj
2021-07-21 09:14:53 -04:00
committed by GitHub
parent 519528daa2
commit 2ce2c83bc9
7 changed files with 116 additions and 12 deletions

View File

@ -12,6 +12,7 @@ class UserSearch
@topic_allowed_users = opts[:topic_allowed_users]
@searching_user = opts[:searching_user]
@include_staged_users = opts[:include_staged_users] || false
@last_seen_users = opts[:last_seen_users] || false
@limit = opts[:limit] || 20
@groups = opts[:groups]
@ -162,6 +163,15 @@ class UserSearch
.each { |id| users << id }
end
# 5. last seen users (for search auto-suggestions)
if @last_seen_users
scoped_users
.order('last_seen_at DESC NULLS LAST')
.limit(@limit - users.size)
.pluck(:id)
.each { |id| users << id }
end
users.to_a
end