Remove subqueries when sending to IN call.
This commit is contained in:
@@ -85,7 +85,7 @@ class DataManagementCog(commands.Cog, name="Table Management"):
|
|||||||
for group in session.scalars(stmt):
|
for group in session.scalars(stmt):
|
||||||
await send_highscore_message(interaction.guild.get_channel(group.ChannelId), group)
|
await send_highscore_message(interaction.guild.get_channel(group.ChannelId), group)
|
||||||
|
|
||||||
await interaction.send(f'User "{user_name}" was removed from all tables.')
|
await interaction.send(f'User "{user_name}" was removed from all tables.', ephemeral=True)
|
||||||
|
|
||||||
@user.subcommand(description="Deletes a user's scores from a category.")
|
@user.subcommand(description="Deletes a user's scores from a category.")
|
||||||
async def from_category(
|
async def from_category(
|
||||||
@@ -140,7 +140,7 @@ class DataManagementCog(commands.Cog, name="Table Management"):
|
|||||||
|
|
||||||
stmt = select(CategoryGroup).where(CategoryGroup.GroupId == int(group_id))
|
stmt = select(CategoryGroup).where(CategoryGroup.GroupId == int(group_id))
|
||||||
group = session.scalar(stmt)
|
group = session.scalar(stmt)
|
||||||
category_ids = select(Category.CategoryId).where(Category.GroupId == int(group_id)).subquery()
|
category_ids = select(Category.CategoryId).where(Category.GroupId == int(group_id))
|
||||||
stmt = select(Score).where(Score.CategoryId.in_(category_ids)).where(Score.UserName == user_name)
|
stmt = select(Score).where(Score.CategoryId.in_(category_ids)).where(Score.UserName == user_name)
|
||||||
|
|
||||||
for score in session.scalars(stmt):
|
for score in session.scalars(stmt):
|
||||||
|
|||||||
+3
-3
@@ -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 no category id, get all users in group.
|
||||||
if category_id == 0:
|
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))
|
stmt = select(distinct(Score.UserName)).where(Score.CategoryId.in_(subq))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -146,8 +146,8 @@ def autofill_users_in_guild(guild_id: int, user_begin: str) -> "list[str]":
|
|||||||
Returns:
|
Returns:
|
||||||
list[str]: All users with submissions in the guild.
|
list[str]: All users with submissions in the guild.
|
||||||
"""
|
"""
|
||||||
group_ids = select(CategoryGroup.GroupId).where(CategoryGroup.GuildId == guild_id).subquery()
|
group_ids = select(CategoryGroup.GroupId).where(CategoryGroup.GuildId == guild_id)
|
||||||
category_ids = select(Category.CategoryId).where(Category.GroupId.in_(group_ids)).subquery()
|
category_ids = select(Category.CategoryId).where(Category.GroupId.in_(group_ids))
|
||||||
stmt = select(distinct(Score.UserName)).where(Score.CategoryId.in_(category_ids))
|
stmt = select(distinct(Score.UserName)).where(Score.CategoryId.in_(category_ids))
|
||||||
users_list: "list[str]" = list(session.scalars(stmt))
|
users_list: "list[str]" = list(session.scalars(stmt))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user