chore(pre-commit): add pre-commit
This commit is contained in:
@@ -7,6 +7,8 @@ from sqlmodel import Field, Relationship, SQLModel
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .user import User
|
||||
|
||||
|
||||
class Team(SQLModel, table=True):
|
||||
__tablename__ = "teams" # pyright: ignore[reportAssignmentType]
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@ import datetime
|
||||
from enum import IntEnum
|
||||
from typing import Any
|
||||
|
||||
import msgpack
|
||||
from pydantic import Field, field_validator
|
||||
|
||||
from .signalr import MessagePackArrayModel
|
||||
from .score import (
|
||||
APIMod as APIModBase,
|
||||
HitResult,
|
||||
)
|
||||
from .signalr import MessagePackArrayModel
|
||||
|
||||
import msgpack
|
||||
from pydantic import Field, field_validator
|
||||
|
||||
|
||||
class APIMod(APIModBase, MessagePackArrayModel): ...
|
||||
|
||||
@@ -87,7 +87,7 @@ class UserAchievement(BaseModel):
|
||||
return LazerUserAchievement(
|
||||
user_id=user_id,
|
||||
achievement_id=self.achievement_id,
|
||||
achieved_at=self.achieved_at
|
||||
achieved_at=self.achieved_at,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ async def oauth_token(
|
||||
raise HTTPException(status_code=400, detail="Refresh token required")
|
||||
|
||||
# 验证刷新令牌
|
||||
token_record =await get_token_by_refresh_token(db, refresh_token)
|
||||
token_record = await get_token_by_refresh_token(db, refresh_token)
|
||||
if not token_record:
|
||||
raise HTTPException(status_code=401, detail="Invalid refresh token")
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
class SignalRException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class InvokeException(SignalRException):
|
||||
def __init__(self, message: str) -> None:
|
||||
self.message = message
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .hub import Hub
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .hub import Hub
|
||||
|
||||
|
||||
class MultiplayerHub(Hub): ...
|
||||
class MultiplayerHub(Hub): ...
|
||||
|
||||
@@ -8,10 +8,8 @@ from .hub import Client, Hub
|
||||
class SpectatorHub(Hub):
|
||||
async def BeginPlaySession(
|
||||
self, client: Client, score_token: int, state: SpectatorState
|
||||
) -> None:
|
||||
...
|
||||
) -> None: ...
|
||||
|
||||
async def SendFrameData(
|
||||
self, client: Client, frame_data: FrameDataBundle
|
||||
) -> None:
|
||||
...
|
||||
) -> None: ...
|
||||
|
||||
@@ -4,7 +4,6 @@ from enum import IntEnum
|
||||
from typing import Any
|
||||
|
||||
import msgpack
|
||||
from pydantic import BaseModel, model_validator
|
||||
|
||||
SEP = b"\x1e"
|
||||
|
||||
@@ -18,6 +17,7 @@ class PacketType(IntEnum):
|
||||
PING = 6
|
||||
CLOSE = 7
|
||||
|
||||
|
||||
class ResultKind(IntEnum):
|
||||
ERROR = 1
|
||||
VOID = 2
|
||||
|
||||
37
app/utils.py
37
app/utils.py
@@ -11,7 +11,6 @@ from app.database import (
|
||||
from app.models.user import (
|
||||
Country,
|
||||
Cover,
|
||||
DailyChallengeStats,
|
||||
GradeCounts,
|
||||
Kudosu,
|
||||
Level,
|
||||
@@ -24,9 +23,7 @@ from app.models.user import (
|
||||
)
|
||||
|
||||
|
||||
async def convert_db_user_to_api_user(
|
||||
db_user: DBUser, ruleset: str = "osu"
|
||||
) -> User:
|
||||
async def convert_db_user_to_api_user(db_user: DBUser, ruleset: str = "osu") -> User:
|
||||
"""将数据库用户模型转换为API用户模型(使用 Lazer 表)"""
|
||||
|
||||
# 从db_user获取基本字段值
|
||||
@@ -71,7 +68,7 @@ async def convert_db_user_to_api_user(
|
||||
kudosu = Kudosu(available=0, total=0)
|
||||
|
||||
# 获取计数信息
|
||||
counts = LazerUserCounts(user_id=user_id)
|
||||
# counts = LazerUserCounts(user_id=user_id)
|
||||
|
||||
# 转换统计信息
|
||||
statistics = Statistics(
|
||||
@@ -176,21 +173,21 @@ async def convert_db_user_to_api_user(
|
||||
rank_history = RankHistory(mode=ruleset, data=rank_history_data)
|
||||
|
||||
# 转换每日挑战统计
|
||||
daily_challenge_stats = None
|
||||
if db_user.daily_challenge_stats:
|
||||
dcs = db_user.daily_challenge_stats
|
||||
daily_challenge_stats = DailyChallengeStats(
|
||||
daily_streak_best=dcs.daily_streak_best,
|
||||
daily_streak_current=dcs.daily_streak_current,
|
||||
last_update=dcs.last_update,
|
||||
last_weekly_streak=dcs.last_weekly_streak,
|
||||
playcount=dcs.playcount,
|
||||
top_10p_placements=dcs.top_10p_placements,
|
||||
top_50p_placements=dcs.top_50p_placements,
|
||||
user_id=dcs.user_id,
|
||||
weekly_streak_best=dcs.weekly_streak_best,
|
||||
weekly_streak_current=dcs.weekly_streak_current,
|
||||
)
|
||||
# daily_challenge_stats = None
|
||||
# if db_user.daily_challenge_stats:
|
||||
# dcs = db_user.daily_challenge_stats
|
||||
# daily_challenge_stats = DailyChallengeStats(
|
||||
# daily_streak_best=dcs.daily_streak_best,
|
||||
# daily_streak_current=dcs.daily_streak_current,
|
||||
# last_update=dcs.last_update,
|
||||
# last_weekly_streak=dcs.last_weekly_streak,
|
||||
# playcount=dcs.playcount,
|
||||
# top_10p_placements=dcs.top_10p_placements,
|
||||
# top_50p_placements=dcs.top_50p_placements,
|
||||
# user_id=dcs.user_id,
|
||||
# weekly_streak_best=dcs.weekly_streak_best,
|
||||
# weekly_streak_current=dcs.weekly_streak_current,
|
||||
# )
|
||||
|
||||
# 转换最高排名
|
||||
rank_highest = None
|
||||
|
||||
Reference in New Issue
Block a user