refactor(scores): rename models of score to match with filename

This commit is contained in:
MingxuanGame
2025-10-04 08:01:38 +00:00
parent 80ba65c746
commit 1163a93053
9 changed files with 103 additions and 97 deletions

View File

@@ -1,7 +1,7 @@
from datetime import datetime, timedelta
from typing import Annotated, Literal
from app.database.best_scores import PPBestScore
from app.database.best_scores import BestScore
from app.database.score import Score, get_leaderboard
from app.dependencies.database import Database
from app.models.mods import int_to_mods, mod_to_save, mods_to_int
@@ -79,7 +79,7 @@ async def get_user_best(
.where(
Score.user_id == user if type == "id" or user.isdigit() else col(Score.user).has(username=user),
Score.gamemode == GameMode.from_int_extra(ruleset_id),
exists().where(col(PPBestScore.score_id) == Score.id),
exists().where(col(BestScore.score_id) == Score.id),
)
.order_by(col(Score.pp).desc())
.options(joinedload(Score.beatmap))

View File

@@ -10,7 +10,7 @@ from app.database import (
User,
UserResp,
)
from app.database.best_scores import PPBestScore
from app.database.best_scores import BestScore
from app.database.events import Event
from app.database.score import LegacyScoreResp, Score, ScoreResp, get_user_first_scores
from app.database.user import SEARCH_INCLUDED
@@ -392,7 +392,7 @@ async def get_user_scores(
where_clause &= Score.pinned_order > 0
order_by = col(Score.pinned_order).asc()
elif type == "best":
where_clause &= exists().where(col(PPBestScore.score_id) == Score.id)
where_clause &= exists().where(col(BestScore.score_id) == Score.id)
order_by = col(Score.pp).desc()
elif type == "recent":
where_clause &= Score.ended_at > utcnow() - timedelta(hours=24)