Remove subqueries when sending to IN call.

This commit is contained in:
alwayscompiling
2022-12-02 18:27:50 -05:00
parent fdd08bc1a2
commit aea2e0beb3
2 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -109,7 +109,7 @@ def autofill_users_in_group_category(guild_id: int, group_id: int, category_id:
# If no category id, get all users in group.
if category_id == 0:
subq = select(Category.CategoryId).where(Category.GroupId == category_group.GroupId).subquery()
subq = select(Category.CategoryId).where(Category.GroupId == category_group.GroupId)
stmt = select(distinct(Score.UserName)).where(Score.CategoryId.in_(subq))
else:
@@ -146,8 +146,8 @@ def autofill_users_in_guild(guild_id: int, user_begin: str) -> "list[str]":
Returns:
list[str]: All users with submissions in the guild.
"""
group_ids = select(CategoryGroup.GroupId).where(CategoryGroup.GuildId == guild_id).subquery()
category_ids = select(Category.CategoryId).where(Category.GroupId.in_(group_ids)).subquery()
group_ids = select(CategoryGroup.GroupId).where(CategoryGroup.GuildId == guild_id)
category_ids = select(Category.CategoryId).where(Category.GroupId.in_(group_ids))
stmt = select(distinct(Score.UserName)).where(Score.CategoryId.in_(category_ids))
users_list: "list[str]" = list(session.scalars(stmt))