Fix the get_matching_users query to work with peewee 2.3+
This commit is contained in:
parent
a6225ad34a
commit
c68d49dfce
1 changed files with 4 additions and 3 deletions
|
@ -601,12 +601,13 @@ def get_matching_users(username_prefix, robot_namespace=None,
|
||||||
(User.robot == True)))
|
(User.robot == True)))
|
||||||
|
|
||||||
query = (User
|
query = (User
|
||||||
.select(User.username, fn.Sum(Team.id), User.robot)
|
.select(User.username, User.robot)
|
||||||
.group_by(User.username)
|
.group_by(User.username)
|
||||||
.where(direct_user_query))
|
.where(direct_user_query))
|
||||||
|
|
||||||
if organization:
|
if organization:
|
||||||
query = (query
|
query = (query
|
||||||
|
.select(User.username, User.robot, fn.Sum(Team.id))
|
||||||
.join(TeamMember, JOIN_LEFT_OUTER)
|
.join(TeamMember, JOIN_LEFT_OUTER)
|
||||||
.join(Team, JOIN_LEFT_OUTER, on=((Team.id == TeamMember.team) &
|
.join(Team, JOIN_LEFT_OUTER, on=((Team.id == TeamMember.team) &
|
||||||
(Team.organization == organization))))
|
(Team.organization == organization))))
|
||||||
|
@ -615,9 +616,9 @@ def get_matching_users(username_prefix, robot_namespace=None,
|
||||||
class MatchingUserResult(object):
|
class MatchingUserResult(object):
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
self.username = args[0]
|
self.username = args[0]
|
||||||
self.is_robot = args[2]
|
self.is_robot = args[1]
|
||||||
if organization:
|
if organization:
|
||||||
self.is_org_member = (args[1] != None)
|
self.is_org_member = (args[2] != None)
|
||||||
else:
|
else:
|
||||||
self.is_org_member = None
|
self.is_org_member = None
|
||||||
|
|
||||||
|
|
Reference in a new issue