correct usage of format_score_string. Make format of view message better.

This commit is contained in:
2023-03-11 15:12:36 -05:00
parent 9c762fb346
commit 37b4d2d62e
2 changed files with 9 additions and 4 deletions
+8 -3
View File
@@ -10,7 +10,7 @@ from sqlalchemy.orm import Session
# pylint: disable=import-error
from utilities.sql_data_classes import Category, CategoryGroup, Score, engine
from utilities.utils import autofill_categories, autofill_groups, format_score_string
from utilities.utils import MAX_LINE_LENGTH, autofill_categories, autofill_groups, format_score_string
class ViewCog(commands.Cog, name="View Command"):
@@ -65,20 +65,25 @@ class ViewCog(commands.Cog, name="View Command"):
scores = d_f.sort_values("Score", ascending=category.IsAscending).reset_index()
# get the longest string
longest_str: int = scores.UserName.map(len).max()
for i, row in scores.iterrows():
str_list.append(
format_score_string(
row["UserName"], row["Score"], group.UsernameLength, category.IsTimeRecord, i + 1, group.PadLength
row["UserName"], row["Score"], longest_str, category.IsTimeRecord, i + 1, MAX_LINE_LENGTH
)
)
message_str: str = f"**{group.GroupName} {category.CategoryName} Leaderboard!**\n"
message_str: str = f"**{group.GroupName} {category.CategoryName} Leaderboard!**\n```"
if len(str_list) == 0:
message_str += "No Submissions!"
else:
for line in str_list:
message_str += f"{line}\n"
message_str += "```"
await interaction.response.send_message(content=message_str)
@leaderboard.on_autocomplete("group_id")
+1 -1
View File
@@ -235,7 +235,7 @@ def format_highscore_message(session: Session, group: CategoryGroup) -> str:
score = processed_group["Score"][ind]
str_list[ind + 1] += format_score_string(
username, score, group.UsernameLength, group.IsTimeRecord, ind + 1, pad_length
username, score, group.UsernameLength, category.IsTimeRecord, ind + 1, pad_length
)
else:
# if not enough entries, pad out