feat(score): support pin score

This commit is contained in:
MingxuanGame
2025-08-10 15:36:39 +00:00
parent a087b0de2e
commit 32e2ac5704
5 changed files with 288 additions and 4 deletions

View File

@@ -15,7 +15,12 @@ from app.calculator import (
)
from app.config import settings
from app.database.team import TeamMember
from app.models.model import RespWithCursor, UTCBaseModel
from app.models.model import (
CurrentUserAttributes,
PinAttributes,
RespWithCursor,
UTCBaseModel,
)
from app.models.mods import APIMod, mods_can_get_pp
from app.models.score import (
INT_TO_MODE,
@@ -122,6 +127,7 @@ class Score(ScoreBase, table=True):
nslider_tail_hit: int | None = Field(default=None, exclude=True)
nsmall_tick_hit: int | None = Field(default=None, exclude=True)
gamemode: GameMode = Field(index=True)
pinned_order: int = Field(default=0, exclude=True)
# optional
beatmap: Beatmap = Relationship()
@@ -166,6 +172,7 @@ class ScoreResp(ScoreBase):
rank_country: int | None = None
position: int | None = None
scores_around: "ScoreAround | None" = None
current_user_attributes: CurrentUserAttributes | None = None
@classmethod
async def from_db(cls, session: AsyncSession, score: Score) -> "ScoreResp":
@@ -234,6 +241,9 @@ class ScoreResp(ScoreBase):
)
or None
)
s.current_user_attributes = CurrentUserAttributes(
pin=PinAttributes(is_pinned=bool(score.pinned_order), score_id=score.id)
)
return s