Only delete specified user. cat_name is already the string.

This commit is contained in:
alwayscompiling
2022-12-02 17:49:11 -05:00
parent 2565b7689f
commit 98dbd30327
2 changed files with 4 additions and 6 deletions
+3 -3
View File
@@ -113,10 +113,10 @@ class DataManagementCog(commands.Cog, name="Table Management"):
stmt = select(Category.CategoryName).where(Category.CategoryId == int(category_id))
category_name = session.scalar(stmt)
stmt = select(Score).where(Score.CategoryId == int(category_id))
stmt = select(Score).where(Score.CategoryId == int(category_id)).where(Score.UserName == user_name)
for score in session.scalars(stmt):
session.delete(score)
# there should only be one because category id and username are a composite primary key in score
session.delete(session.scalar(stmt))
session.commit()
await send_highscore_message(interaction.guild.get_channel(group.ChannelId), group)
+1 -3
View File
@@ -48,9 +48,7 @@ def autofill_categories(guild_id: int, group_id: int, category_begin: str) -> "d
# else find all categories that start with category_begin
# TODO is it better to have sql handle the starts with or python?
categories: dict = {
cat_name: cat_id
for cat_name, cat_id in categories_dict.items()
if category_begin.lower() in cat_name.CategoryName.lower()
cat_name: cat_id for cat_name, cat_id in categories_dict.items() if category_begin.lower() in cat_name.lower()
}
return categories