refactor(detector): more readable
This commit is contained in:
@@ -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_
|
||||
)
|
||||
|
||||
@@ -183,10 +183,6 @@ class Beatmapset(AsyncAttrs, BeatmapsetBase, table=True):
|
||||
if not beatmapset:
|
||||
resp = await fetcher.get_beatmapset(sid)
|
||||
beatmapset = await cls.from_resp(session, resp)
|
||||
# 检查可疑谱面
|
||||
from app.calculator import get_suspscious_beatmap
|
||||
|
||||
await get_suspscious_beatmap(sid, session)
|
||||
return beatmapset
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import asyncio
|
||||
from collections.abc import Sequence
|
||||
from datetime import UTC, date, datetime
|
||||
import json
|
||||
@@ -726,9 +725,7 @@ async def process_score(
|
||||
)
|
||||
if can_get_pp:
|
||||
beatmap_raw = await fetcher.get_or_fetch_beatmap_raw(redis, beatmap_id)
|
||||
pp = await asyncio.get_event_loop().run_in_executor(
|
||||
None, calculate_pp, score, beatmap_raw
|
||||
)
|
||||
pp = await calculate_pp(score, beatmap_raw, session)
|
||||
score.pp = pp
|
||||
session.add(score)
|
||||
user_id = user.id
|
||||
|
||||
Reference in New Issue
Block a user