From 9a7fc007bc9cf8046bed792ef110d82e67874177 Mon Sep 17 00:00:00 2001 From: SoulGateKey Date: Fri, 4 Apr 2025 05:42:53 +0800 Subject: [PATCH] standardization KaleidxScope variable names --- titles/mai2/dx.py | 4 ++-- titles/mai2/prism.py | 15 +++++++-------- titles/mai2/schema/score.py | 18 +++++++++--------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/titles/mai2/dx.py b/titles/mai2/dx.py index 82e99f9..9b8b547 100644 --- a/titles/mai2/dx.py +++ b/titles/mai2/dx.py @@ -284,8 +284,8 @@ class Mai2DX(Mai2Base): # added in PRiSM if "userKaleidxScopeList" in upsert and len(upsert["userKaleidxScopeList"]) > 0: - for kaleidx_scope in upsert["userKaleidxScopeList"]: - await self.data.score.put_user_kaleidx_scope(user_id, kaleidx_scope) + for kaleidxscope in upsert["userKaleidxScopeList"]: + await self.data.score.put_user_kaleidxscope(user_id, kaleidxscope) return {"returnCode": 1, "apiName": "UpsertUserAllApi"} diff --git a/titles/mai2/prism.py b/titles/mai2/prism.py index 5d0da41..5db7c8a 100644 --- a/titles/mai2/prism.py +++ b/titles/mai2/prism.py @@ -4,7 +4,6 @@ from core.config import CoreConfig from titles.mai2.buddiesplus import Mai2BuddiesPlus from titles.mai2.const import Mai2Constants from titles.mai2.config import Mai2Config -from titles.mai2.schema.score import kaleidx_scope class Mai2Prism(Mai2BuddiesPlus): @@ -50,18 +49,18 @@ class Mai2Prism(Mai2BuddiesPlus): } async def handle_get_user_kaleidx_scope_api_request(self, data: Dict) -> Dict: - kaleidx_scope = await self.data.score.get_user_kaleidx_scope_list(data["userId"]) + kaleidxscope = await self.data.score.get_user_kaleidxscope_list(data["userId"]) - if kaleidx_scope is None: + if kaleidxscope is None: return {"userId": data["userId"], "userKaleidxScopeList":[]} - kaleidx_scope_list = [] - for kaleidx_scope_data in kaleidx_scope: - tmp = kaleidx_scope_data._asdict() + kaleidxscope_list = [] + for kaleidxscope_data in kaleidxscope: + tmp = kaleidxscope_data._asdict() tmp.pop("user") tmp.pop("id") - kaleidx_scope_list.append(tmp) + kaleidxscope_list.append(tmp) return { "userId": data["userId"], - "userKaleidxScopeList": kaleidx_scope_list + "userKaleidxScopeList": kaleidxscope_list } \ No newline at end of file diff --git a/titles/mai2/schema/score.py b/titles/mai2/schema/score.py index f3e7002..d03dba4 100644 --- a/titles/mai2/schema/score.py +++ b/titles/mai2/schema/score.py @@ -175,8 +175,8 @@ playlog_2p = Table( mysql_charset="utf8mb4", ) -kaleidx_scope = Table( - "mai2_score_kaleidx_scope", +kaleidxscope = Table( + "mai2_score_kaleidxscope", metadata, Column("id", Integer, primary_key=True, nullable=False), Column( @@ -481,21 +481,21 @@ class Mai2ScoreData(BaseData): return None return result.scalar() - async def get_user_kaleidx_scope_list(self, user_id: int) -> Optional[List[Row]]: - sql = kaleidx_scope.select(kaleidx_scope.c.user == user_id) + async def get_user_kaleidxscope_list(self, user_id: int) -> Optional[List[Row]]: + sql = kaleidxscope.select(kaleidxscope.c.user == user_id) result = await self.execute(sql) if result is None: return None return result.fetchall() - async def put_user_kaleidx_scope(self, user_id: int, user_kaleidx_scope_data: Dict) -> Optional[int]: - user_kaleidx_scope_data["user"] = user_id - sql = insert(kaleidx_scope).values(**user_kaleidx_scope_data) + async def put_user_kaleidxscope(self, user_id: int, user_kaleidxscope_data: Dict) -> Optional[int]: + user_kaleidxscope_data["user"] = user_id + sql = insert(kaleidxscope).values(**user_kaleidxscope_data) - conflict = sql.on_duplicate_key_update(**user_kaleidx_scope_data) + conflict = sql.on_duplicate_key_update(**user_kaleidxscope_data) result = await self.execute(conflict) if result is None: - self.logger.error(f"put_user_kaleidx_scope: Failed to insert! user_id {user_id}") + self.logger.error(f"put_user_kaleidxscope: Failed to insert! user_id {user_id}") return None return result.lastrowid \ No newline at end of file