correct usage of format_score_string. Make format of view message better.
This commit is contained in:
@@ -10,7 +10,7 @@ from sqlalchemy.orm import Session
|
|||||||
|
|
||||||
# pylint: disable=import-error
|
# pylint: disable=import-error
|
||||||
from utilities.sql_data_classes import Category, CategoryGroup, Score, engine
|
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"):
|
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()
|
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():
|
for i, row in scores.iterrows():
|
||||||
str_list.append(
|
str_list.append(
|
||||||
format_score_string(
|
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:
|
if len(str_list) == 0:
|
||||||
message_str += "No Submissions!"
|
message_str += "No Submissions!"
|
||||||
else:
|
else:
|
||||||
for line in str_list:
|
for line in str_list:
|
||||||
message_str += f"{line}\n"
|
message_str += f"{line}\n"
|
||||||
|
|
||||||
|
message_str += "```"
|
||||||
|
|
||||||
await interaction.response.send_message(content=message_str)
|
await interaction.response.send_message(content=message_str)
|
||||||
|
|
||||||
@leaderboard.on_autocomplete("group_id")
|
@leaderboard.on_autocomplete("group_id")
|
||||||
|
|||||||
+1
-1
@@ -235,7 +235,7 @@ def format_highscore_message(session: Session, group: CategoryGroup) -> str:
|
|||||||
score = processed_group["Score"][ind]
|
score = processed_group["Score"][ind]
|
||||||
|
|
||||||
str_list[ind + 1] += format_score_string(
|
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:
|
else:
|
||||||
# if not enough entries, pad out
|
# if not enough entries, pad out
|
||||||
|
|||||||
Reference in New Issue
Block a user