Make sure robot accounts always show up first in entity search

Fixes https://www.pivotaltracker.com/story/show/136277321
Fixes #2241
This commit is contained in:
Joseph Schorr 2016-12-16 15:04:30 -05:00
parent f72185f527
commit 58b7481a63

View file

@ -579,7 +579,7 @@ def get_matching_users(username_prefix, robot_namespace=None, organization=None,
if robot_namespace:
robot_prefix = format_robot_username(robot_namespace, username_prefix)
robot_search = _basequery.prefix_search(User.username, robot_prefix)
direct_user_query = (direct_user_query | (robot_search & (User.robot == True)))
direct_user_query = ((robot_search & (User.robot == True)) | direct_user_query)
query = (User
.select(User.id, User.username, User.email, User.robot)
@ -591,7 +591,8 @@ def get_matching_users(username_prefix, robot_namespace=None, organization=None,
.select(User.id, User.username, User.email, User.robot, fn.Sum(Team.id))
.join(TeamMember, JOIN_LEFT_OUTER)
.join(Team, JOIN_LEFT_OUTER, on=((Team.id == TeamMember.team) &
(Team.organization == organization))))
(Team.organization == organization)))
.order_by(User.robot.desc()))
class MatchingUserResult(object):
def __init__(self, *args):