Skip to content

🐛 修爆炸 #528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ..base import ArCounts, FailedModel, P, SuccessModel


class League(BaseModel):
class BaseLeague(BaseModel):
gamesplayed: int
gameswon: int
tr: float
Expand All @@ -16,21 +16,28 @@ class League(BaseModel):
bestrank: ValidRank
glicko: float
rd: float
apm: float
pps: float
vs: float
decaying: bool


class Entry(BaseModel):
class InvalidLeague(BaseLeague):
apm: None
vs: None


class League(BaseLeague):
apm: float
vs: float


class BaseEntry(BaseModel):
id: str = Field(..., alias='_id')
username: str
role: Literal['anon', 'user', 'bot', 'halfmod', 'mod', 'admin', 'sysop']
ts: datetime | None = None
xp: float
country: str | None = None
supporter: bool | None = None
league: League
gamesplayed: int
gameswon: int
gametime: float
Expand All @@ -39,8 +46,16 @@ class Entry(BaseModel):
p: P


class InvalidEntry(BaseEntry):
league: InvalidLeague


class Entry(BaseEntry):
league: League


class Data(BaseModel):
entries: list[Entry]
entries: list[Entry | InvalidEntry]


class BySuccessModel(SuccessModel):
Expand Down
2 changes: 2 additions & 0 deletions nonebot_plugin_tetris_stats/games/tetrio/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .api.leaderboards import by
from .api.schemas.base import P
from .api.schemas.leaderboards import Parameter
from .api.schemas.leaderboards.by import Entry
from .constant import GAME_TYPE

command.add(
Expand Down Expand Up @@ -84,6 +85,7 @@ async def _(
join_at=None,
)
for i in league.data.entries
if isinstance(i, Entry)
],
),
)
Expand Down
2 changes: 1 addition & 1 deletion nonebot_plugin_tetris_stats/games/tetrio/rank/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async def get_tetra_league_data() -> None:

players: list[Entry] = []
for result in results:
players.extend(result.data.entries)
players.extend([i for i in result.data.entries if isinstance(i, Entry)])
players.sort(key=lambda x: x.league.tr, reverse=True)

rank_player_mapping: defaultdict[Rank, list[Entry]] = defaultdict(list)
Expand Down
Loading