changeset 8645:a86569aef600

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.
author Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
date Fri, 25 Sep 2020 11:14:12 +0200
parents e24531aa2449
children 96c86063278c
files kallithea/controllers/home.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/home.py	Sat Jun 27 20:30:00 2020 +0200
+++ b/kallithea/controllers/home.py	Fri Sep 25 11:14:12 2020 +0200
@@ -172,8 +172,8 @@
                     .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) \