Fix the get_matching_users query to work with peewee 2.3+

This commit is contained in:
Jake Moshenko 2014-09-22 18:42:48 -04:00
parent a6225ad34a
commit c68d49dfce

View file

@ -601,12 +601,13 @@ def get_matching_users(username_prefix, robot_namespace=None,
(User.robot == True)))
query = (User
.select(User.username, fn.Sum(Team.id), User.robot)
.select(User.username, User.robot)
.group_by(User.username)
.where(direct_user_query))
if organization:
query = (query
.select(User.username, User.robot, fn.Sum(Team.id))
.join(TeamMember, JOIN_LEFT_OUTER)
.join(Team, JOIN_LEFT_OUTER, on=((Team.id == TeamMember.team) &
(Team.organization == organization))))
@ -615,9 +616,9 @@ def get_matching_users(username_prefix, robot_namespace=None,
class MatchingUserResult(object):
def __init__(self, *args):
self.username = args[0]
self.is_robot = args[2]
self.is_robot = args[1]
if organization:
self.is_org_member = (args[1] != None)
self.is_org_member = (args[2] != None)
else:
self.is_org_member = None