diff --git a/app/api/public/user_stats.py b/app/api/public/user_stats.py index 13008d9..9e66e57 100644 --- a/app/api/public/user_stats.py +++ b/app/api/public/user_stats.py @@ -7,7 +7,7 @@ from app.errors import ErrorCode from app.common_types import GameMode from app.common_types import RelaxMode -from app.common_types import Mode +from app.common_types import AkatsukiMode from app.usecases import user_stats router = APIRouter(tags=["(Public) User Stats API"]) @@ -30,9 +30,9 @@ async def get_user_stats( game_mode: GameMode = Query(...), relax_mode: RelaxMode = Query(...), ) -> Response: - mode = Mode.from_game_mode_and_relax_mode(game_mode, relax_mode) + akatsuki_mode = AkatsukiMode.from_game_mode_and_relax_mode(game_mode, relax_mode) - response = await user_stats.fetch_one_by_user_id_and_mode(user_id, mode) + response = await user_stats.fetch_one_by_user_id_and_akatsuki_mode(user_id, akatsuki_mode) if isinstance(response, Error): return JSONResponse( content=response.model_dump(), diff --git a/app/common_types.py b/app/common_types.py index 85a26c0..2f2b4e3 100644 --- a/app/common_types.py +++ b/app/common_types.py @@ -53,7 +53,7 @@ class RelaxMode(IntEnum): AUTOPILOT = 2 -class Mode(IntEnum): +class AkatsukiMode(IntEnum): OSU = 0 TAIKO = 1 CATCH = 2 @@ -69,12 +69,12 @@ class Mode(IntEnum): def from_game_mode_and_relax_mode( game_mode: GameMode, relax_mode: RelaxMode, - ) -> "Mode": + ) -> "AkatsukiMode": if relax_mode is RelaxMode.VANILLA: - return Mode(game_mode.value) + return AkatsukiMode(game_mode.value) elif relax_mode is RelaxMode.RELAX and game_mode is not GameMode.MANIA: - return Mode(game_mode.value + 4) + return AkatsukiMode(game_mode.value + 4) elif relax_mode is RelaxMode.AUTOPILOT and game_mode is GameMode.OSU: - return Mode.AUTOPILOT_OSU + return AkatsukiMode.AUTOPILOT_OSU else: raise ValueError("Unknown game_mode and relax_mode combo") diff --git a/app/repositories/user_stats.py b/app/repositories/user_stats.py index e7338da..e1f14fb 100644 --- a/app/repositories/user_stats.py +++ b/app/repositories/user_stats.py @@ -1,6 +1,6 @@ from pydantic import BaseModel -from app.common_types import Mode +from app.common_types import AkatsukiMode import app.state @@ -30,17 +30,17 @@ class UserStats(BaseModel): xh_count, x_count, sh_count, s_count, a_count, b_count, c_count, d_count, max_combo """ -async def fetch_one_by_user_id_and_mode( +async def fetch_one_by_user_id_and_akatsuki_mode( user_id: int, - mode: Mode, + akatsuki_mode: AkatsukiMode, ) -> UserStats | None: query = f""" SELECT {READ_PARAMS} FROM user_stats WHERE user_id = :user_id - AND mode = :mode + AND mode = :akatsuki_mode """ - params = {"user_id": user_id, "mode": mode.value} + params = {"user_id": user_id, "akatsuki_mode": akatsuki_mode.value} user_stats = await app.state.database.fetch_one(query, params) if user_stats is None: diff --git a/app/usecases/user_stats.py b/app/usecases/user_stats.py index 9d81573..8a42d7c 100644 --- a/app/usecases/user_stats.py +++ b/app/usecases/user_stats.py @@ -1,11 +1,11 @@ -from app.common_types import Mode +from app.common_types import AkatsukiMode from app.models.user_stats import UserStats from app.errors import Error from app.errors import ErrorCode from app.repositories import user_stats -async def fetch_one_by_user_id_and_mode(user_id: int, mode: Mode) -> UserStats | Error: - stats = await user_stats.fetch_one_by_user_id_and_mode(user_id, mode) +async def fetch_one_by_user_id_and_akatsuki_mode(user_id: int, mode: AkatsukiMode) -> UserStats | Error: + stats = await user_stats.fetch_one_by_user_id_and_akatsuki_mode(user_id, mode) if stats is None: return Error( error_code=ErrorCode.NOT_FOUND,