User mention search should prioritize users with access to the current category

The scoping is done with this order if the site setting 'enable_name?` is enabled like it is here:

order(DB.sql_fragment("CASE WHEN username_lower LIKE ? THEN 0 ELSE 1 END ASC", @term_like))

So we get:

ORDER BY CASE WHEN username_lower LIKE 'arpit%' THEN 0 ELSE 1 END ASC, last_seen_at DESC LIMIT 19

This means username matches are unconditionally first.

We could change this I guess, but I worry that this will lead to a reverse problem.

4 Likes