refactor(detector): more readable

This commit is contained in:
MingxuanGame
2025-08-15 08:52:01 +00:00
parent 7c7c68c163
commit 814d9c4618
7 changed files with 40 additions and 110 deletions

View File

@@ -3,6 +3,7 @@ from datetime import datetime
import hashlib
from typing import TYPE_CHECKING
from app.calculator import calculate_beatmap_attribute
from app.config import settings
from app.models.beatmap import BeatmapAttributes, BeatmapRankStatus
from app.models.mods import APIMod
@@ -203,7 +204,7 @@ class BeatmapResp(BeatmapBase):
class BannedBeatmaps(SQLModel, table=True):
__tablename__ = "banned_beatmaps" # pyright: ignore[reportAssignmentType]
id: int = Field(primary_key=True, index=True)
id: int | None = Field(primary_key=True, index=True, default=None)
beatmap_id: int = Field(index=True)
@@ -221,9 +222,6 @@ async def calculate_beatmap_attributes(
if await redis.exists(key):
return BeatmapAttributes.model_validate_json(await redis.get(key)) # pyright: ignore[reportArgumentType]
resp = await fetcher.get_or_fetch_beatmap_raw(redis, beatmap_id)
# 延迟导入以解决循环导入问题
from app.calculator import calculate_beatmap_attribute
attr = await asyncio.get_event_loop().run_in_executor(
None, calculate_beatmap_attribute, resp, ruleset, mods_
)