Fix lint smells and update model usage in view.
This commit is contained in:
Vendored
+1
@@ -5,6 +5,7 @@
|
|||||||
"highscore",
|
"highscore",
|
||||||
"highscores",
|
"highscores",
|
||||||
"imcompiling",
|
"imcompiling",
|
||||||
|
"iterrows",
|
||||||
"nextcord",
|
"nextcord",
|
||||||
"ondelete"
|
"ondelete"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ import pandas as pd
|
|||||||
from nextcord.ext import commands
|
from nextcord.ext import commands
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
from sqlmodel import col
|
||||||
|
|
||||||
from database.db import Category, CategoryGroup, Score, engine
|
from database.db import engine
|
||||||
|
from database.models import Category, CategoryGroup, Score
|
||||||
from utilities.utils import MAX_LINE_LENGTH, autofill_categories, autofill_groups, format_score_string
|
from utilities.utils import MAX_LINE_LENGTH, autofill_categories, autofill_groups, format_score_string
|
||||||
|
|
||||||
|
|
||||||
@@ -46,17 +48,17 @@ class ViewCog(commands.Cog, name="View Command"):
|
|||||||
|
|
||||||
# get group, category, and all scores sorted correctly.
|
# get group, category, and all scores sorted correctly.
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
stmt = select(CategoryGroup).where(CategoryGroup.GroupId == int(group_id))
|
stmt = select(CategoryGroup).where(col(CategoryGroup.id) == int(group_id))
|
||||||
group = session.scalar(stmt)
|
group = session.scalar(stmt)
|
||||||
|
|
||||||
stmt = select(Category).where(Category.CategoryId == int(category_id))
|
stmt = select(Category).where(col(Category.id) == int(category_id))
|
||||||
category = session.scalar(stmt)
|
category = session.scalar(stmt)
|
||||||
|
|
||||||
d_f = pd.read_sql_query(
|
d_f = pd.read_sql_query(
|
||||||
sql=session.query(Score).where(Score.CategoryId == category_id).statement, con=engine
|
sql=session.query(Score).where(col(Score.category_id) == category_id).statement, con=engine
|
||||||
)
|
)
|
||||||
|
|
||||||
scores = d_f.sort_values("Score", ascending=category.IsAscending).reset_index()
|
scores = d_f.sort_values("Score", ascending=category.is_ascending).reset_index()
|
||||||
|
|
||||||
# get the longest string
|
# get the longest string
|
||||||
longest_str: int = scores.UserName.map(len).max()
|
longest_str: int = scores.UserName.map(len).max()
|
||||||
@@ -67,13 +69,13 @@ class ViewCog(commands.Cog, name="View Command"):
|
|||||||
row["UserName"],
|
row["UserName"],
|
||||||
row["Score"],
|
row["Score"],
|
||||||
longest_str,
|
longest_str,
|
||||||
category.IsTimeRecord,
|
category.is_time_record,
|
||||||
i + 1, # type: ignore[reportOperatorIssue]
|
i + 1, # type: ignore[reportOperatorIssue]
|
||||||
MAX_LINE_LENGTH,
|
MAX_LINE_LENGTH,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
message_str: str = f"**{group.GroupName} {category.CategoryName} Leaderboard!**\n```"
|
message_str: str = f"**{group.name} {category.name} Leaderboard!**\n```"
|
||||||
if len(str_list) == 0:
|
if len(str_list) == 0:
|
||||||
message_str += "No Submissions!"
|
message_str += "No Submissions!"
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user