users: autocomplete now sorts by matched username to show best matches first.
This commit is contained in:
parent
b5f86e3b64
commit
dd344bb96b
1 changed files with 5 additions and 1 deletions
|
|
@ -42,7 +42,7 @@ from rhodecode.lib.exceptions import (
|
|||
from rhodecode.lib.caching_query import FromCache
|
||||
from rhodecode.model import BaseModel
|
||||
from rhodecode.model.db import (
|
||||
_hash_key, true, false, or_, joinedload, User, UserToPerm,
|
||||
_hash_key, func, true, false, or_, joinedload, User, UserToPerm,
|
||||
UserEmailMap, UserIpMap, UserLog)
|
||||
from rhodecode.model.meta import Session
|
||||
from rhodecode.model.auth_token import AuthTokenModel
|
||||
|
|
@ -96,7 +96,11 @@ class UserModel(BaseModel):
|
|||
User.username.ilike(ilike_expression)
|
||||
)
|
||||
)
|
||||
# sort by len to have top most matches first
|
||||
query = query.order_by(func.length(User.username))\
|
||||
.order_by(User.username)
|
||||
query = query.limit(limit)
|
||||
|
||||
users = query.all()
|
||||
|
||||
_users = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue