Correct score submission value. Parse times correctly.
This commit is contained in:
@@ -33,7 +33,7 @@ class VerificationView(nextcord.ui.View):
|
|||||||
elif field["name"] == "CategoryId":
|
elif field["name"] == "CategoryId":
|
||||||
category_id = int(field["value"])
|
category_id = int(field["value"])
|
||||||
elif field["name"] == "Score":
|
elif field["name"] == "Score":
|
||||||
score = float(field["value"])
|
score = field["value"]
|
||||||
elif field["name"] == "User Name":
|
elif field["name"] == "User Name":
|
||||||
user = field["value"]
|
user = field["value"]
|
||||||
|
|
||||||
|
|||||||
+12
-2
@@ -315,7 +315,7 @@ async def send_highscore_message(channel: nextcord.TextChannel, group: CategoryG
|
|||||||
|
|
||||||
|
|
||||||
async def submit_score(
|
async def submit_score(
|
||||||
interaction: nextcord.Interaction, group_id: int, category_id: int, username: str, score: float
|
interaction: nextcord.Interaction, group_id: int, category_id: int, username: str, score: str
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Adds passed score to group. Then updates group message by calling send_highscore_message.
|
Adds passed score to group. Then updates group message by calling send_highscore_message.
|
||||||
@@ -326,9 +326,19 @@ async def submit_score(
|
|||||||
group (CategoryGroup): group to submit score to.
|
group (CategoryGroup): group to submit score to.
|
||||||
category_id (Category): Category to submit score to.
|
category_id (Category): Category to submit score to.
|
||||||
username (str): The user who submitted the score.
|
username (str): The user who submitted the score.
|
||||||
score (float): Score to submit.
|
score (str): Score to submit. Need to convert to correct type.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
stmt = select(Category.IsTimeRecord).where(Category.CategoryId == category_id)
|
||||||
|
is_time_record = session.scalar(stmt)
|
||||||
|
|
||||||
|
if is_time_record:
|
||||||
|
minutes = float(score.split(":", maxsplit=1)[0])
|
||||||
|
seconds = float(score.split(":", maxsplit=1)[1])
|
||||||
|
score = (minutes * 60) + seconds
|
||||||
|
else:
|
||||||
|
score = float(score)
|
||||||
|
|
||||||
score_obj = Score(UserName=username, Score=score, CategoryId=category_id)
|
score_obj = Score(UserName=username, Score=score, CategoryId=category_id)
|
||||||
session.add(score_obj)
|
session.add(score_obj)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|||||||
Reference in New Issue
Block a user