Revert "fix: drop groupby"

This reverts commit cd2a311f54.
This commit is contained in:
Angus Hollands
2025-07-28 09:54:46 +01:00
parent cd2a311f54
commit 98ef84e774

View File

@@ -141,6 +141,8 @@ class UserListAPIHandler(APIHandler):
.join(orm.Spawner, orm.User._orm_spawners) .join(orm.Spawner, orm.User._orm_spawners)
# this implicitly gets Users with *any* active server # this implicitly gets Users with *any* active server
.filter(orm.Spawner.server != None) .filter(orm.Spawner.server != None)
# group-by ensures the count is correct
.group_by(orm.User.id)
) )
if state_filter == "ready": if state_filter == "ready":
# have to post-process query results because active vs ready # have to post-process query results because active vs ready
@@ -155,6 +157,7 @@ class UserListAPIHandler(APIHandler):
query = ( query = (
query.outerjoin(orm.Spawner, orm.User._orm_spawners) query.outerjoin(orm.Spawner, orm.User._orm_spawners)
.outerjoin(orm.Server, orm.Spawner.server) .outerjoin(orm.Server, orm.Spawner.server)
.group_by(orm.User.id)
.having(func.count(orm.Server.id) == 0) .having(func.count(orm.Server.id) == 0)
) )
elif state_filter: elif state_filter: