# HG changeset patch # User Thomas De Schampheleire # Date 2020-09-25 11:14:12 # Node ID a86569aef60025742fc18903a51bb1e7aa5dbcdb # Parent e24531aa2449703fd85b23dd037bcaab543096c2 autocomplete: also query 'firstname lastname' and 'lastname firstname' combinations The autocomplete functionality for user names, e.g. in pull request reviewer lists, @mentions, etc. would match the input term only on firstname, lastname or username, but not a combination of firstname lastname. This is a problem when there are many matches on the same firstname or lastname, in particular with Chinese names like 'Wang', 'Cheng', etc. If you know the full name and type it, you would not get any matches. Instead, adapt the queries to also match on 'firstname lastname' and 'lastname firstname'. This means that simple matching on only username or only lastname, can be removed. diff --git a/kallithea/controllers/home.py b/kallithea/controllers/home.py --- a/kallithea/controllers/home.py +++ b/kallithea/controllers/home.py @@ -172,8 +172,8 @@ class HomeController(BaseController): .filter(User.active == True) \ .filter(or_( User.username.ilike("%%" + query + "%%"), - User.name.ilike("%%" + query + "%%"), - User.lastname.ilike("%%" + query + "%%"), + User.name.concat(' ').concat(User.lastname).ilike("%%" + query + "%%"), + User.lastname.concat(' ').concat(User.name).ilike("%%" + query + "%%"), )) \ .order_by(User.username) \ .limit(500) \