diff --git a/cogs/submission/verification_view.py b/cogs/submission/verification_view.py index da9438b..3ce5480 100644 --- a/cogs/submission/verification_view.py +++ b/cogs/submission/verification_view.py @@ -33,7 +33,7 @@ class VerificationView(nextcord.ui.View): elif field["name"] == "CategoryId": category_id = int(field["value"]) elif field["name"] == "Score": - score = float(field["value"]) + score = field["value"] elif field["name"] == "User Name": user = field["value"] diff --git a/utilities/utils.py b/utilities/utils.py index 0823792..2655580 100644 --- a/utilities/utils.py +++ b/utilities/utils.py @@ -315,7 +315,7 @@ async def send_highscore_message(channel: nextcord.TextChannel, group: CategoryG 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: """ 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. category_id (Category): Category to submit score to. 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) session.add(score_obj) session.commit()