mirror of
https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
synced 2026-02-03 18:45:32 +08:00
🐛 修复打过但是没数据的爆炸
为啥会没数据??
This commit is contained in:
@@ -1,10 +1,21 @@
|
||||
from functools import partial
|
||||
from typing import Literal
|
||||
|
||||
from nonebot.compat import PYDANTIC_V2
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from ...typing import Rank, S1Rank, S1ValidRank
|
||||
from ..base import SuccessModel
|
||||
|
||||
if PYDANTIC_V2:
|
||||
from pydantic import field_validator
|
||||
|
||||
custom_validator = partial(field_validator, mode='before')
|
||||
else:
|
||||
from pydantic import validator
|
||||
|
||||
custom_validator = partial(validator, pre=True, always=True) # type: ignore[assignment, arg-type]
|
||||
|
||||
|
||||
class PastInner(BaseModel):
|
||||
season: str
|
||||
@@ -75,6 +86,13 @@ class NeverRatedData(BaseData):
|
||||
percentile: Literal[-1]
|
||||
percentile_rank: Literal['z']
|
||||
|
||||
@custom_validator('apm', 'pps', 'vs')
|
||||
@classmethod
|
||||
def _(cls, value: float | None) -> float:
|
||||
if value is None:
|
||||
return 0
|
||||
return value
|
||||
|
||||
|
||||
class RatedData(BaseData):
|
||||
gamesplayed: int
|
||||
|
||||
Reference in New Issue
Block a user