fix(score): cannot fetch leaderboard with mods

This commit is contained in:
MingxuanGame
2025-08-18 12:49:06 +00:00
parent 8735f3032c
commit b5b14f5466
2 changed files with 2 additions and 4 deletions

View File

@@ -2,7 +2,6 @@ from datetime import UTC, datetime, timedelta
import json
from typing import TYPE_CHECKING, NotRequired, TypedDict
from app.database.pp_best_score import PPBestScore
from app.models.model import UTCBaseModel
from app.models.score import GameMode
from app.models.user import Country, Page
@@ -265,6 +264,7 @@ class UserResp(UserBase):
from .best_score import BestScore
from .favourite_beatmapset import FavouriteBeatmapset
from .pp_best_score import PPBestScore
from .relationship import Relationship, RelationshipResp, RelationshipType
from .score import Score

View File

@@ -314,7 +314,7 @@ async def _score_where(
text(
"JSON_CONTAINS(total_score_best_scores.mods, :w)"
" AND JSON_CONTAINS(:w, total_score_best_scores.mods)"
) # pyright: ignore[reportArgumentType]
).params(w=json.dumps(mods)) # pyright: ignore[reportArgumentType]
)
else:
return None
@@ -346,8 +346,6 @@ async def get_leaderboard(
.limit(limit)
.order_by(col(BestScore.total_score).desc())
)
if mods:
query = query.params(w=json.dumps(mods))
extra_need = 0
for s in await session.exec(query):
if s.user_id in scores: