fix(score): sort mods to ensure to find scores

This commit is contained in:
MingxuanGame
2025-08-18 12:58:10 +00:00
parent b5b14f5466
commit 8d5f71f7d8
2 changed files with 9 additions and 3 deletions

View File

@@ -6,7 +6,7 @@ from typing import Literal
from app.database.pp_best_score import PPBestScore
from app.database.score import Score, get_leaderboard
from app.dependencies.database import get_db
from app.models.mods import int_to_mods, mods_to_int
from app.models.mods import int_to_mods, mod_to_save, mods_to_int
from app.models.score import GameMode, LeaderboardType
from .router import AllStrModel, router
@@ -172,7 +172,7 @@ async def get_scores(
beatmap_id,
GameMode.from_int_extra(ruleset_id),
LeaderboardType.GLOBAL,
[mod["acronym"] for mod in int_to_mods(mods)],
mod_to_save(int_to_mods(mods)),
limit=limit,
)
return [await V1Score.from_db(score) for score in scores]

View File

@@ -242,7 +242,13 @@ async def get_beatmap_scores(
)
all_scores, user_score, count = await get_leaderboard(
db, beatmap_id, mode, type=type, user=current_user, limit=limit, mods=mods
db,
beatmap_id,
mode,
type=type,
user=current_user,
limit=limit,
mods=sorted(mods),
)
user_score_resp = await ScoreResp.from_db(db, user_score) if user_score else None