Defect #44431
openmentions can't find a user
Description
while using @ for the user mention, redmine can't match input after @ to a real user if number of project users is significant
main reason is that there is a logic flaw
WatchersController is defining users_for_mention method
logic is:
if params[:q].blank? && @project.present?
scope = @project.principals.assignable_watchers.limit(100)
else
scope = Principal.assignable_watchers.limit(10)
end
that mean if you press @ in the issue text editor, first 10 users are being selected and then query filter is applied, so if you user is 11th on a list - there sill be an empty list
I suggest to not limit scope there, but after matching users to a query
Updated by Janusz Harkot 24 days ago
there are performance changes Patch #44190: Improve @mention performance by limiting initial suggestions should be addressed too... is there an option to send quary (`q`) to the database - to limit matched users?
Updated by Holger Just 18 days ago
- Description updated (diff)
- Status changed from New to Needs feedback
WatchersController#users_for_mention is building a SQL query scope. As such, the limit to 10 results is only applied after filtering the list with the supplied query (which in the case of the mentions autocomplete is the text entered after the @ character).
As such, we return either up to 100 users from the project if no further text was entered yet, or we return up to 10 users matching the query. If the desired user is not yet part of the result, the user has to enter a more specific search term. If this does not work as intended for you, please provide a concrete reproducible example demonstrating your specific issue.
In any case, returning an unbound result here is inadvisable since this could result in arbitrarily large responses which would have to be dealt with in the frontend. Otherwise, it could could result in slowdowns or even crashes there.
Updated by Janusz Harkot 18 days ago
you have 11 users: qwer01 till qwer10 and zxc01
if you type 'zxc' it will not find a user, because initial db query will be limited to 10 users
and then filtered for 'zxc'
so zxc01 user will not be on a list - no match - an empty list will be returned
Updated by Janusz Harkot 18 days ago
that is why my suggestion was to put query to the initial db query, not to search on an already limited result