standardization KaleidxScope variable names

pull/205/head
SoulGateKey 2025-04-04 05:42:53 +08:00
parent cc7afa6b67
commit 9a7fc007bc
3 changed files with 18 additions and 19 deletions

View File

@ -284,8 +284,8 @@ class Mai2DX(Mai2Base):
# added in PRiSM # added in PRiSM
if "userKaleidxScopeList" in upsert and len(upsert["userKaleidxScopeList"]) > 0: if "userKaleidxScopeList" in upsert and len(upsert["userKaleidxScopeList"]) > 0:
for kaleidx_scope in upsert["userKaleidxScopeList"]: for kaleidxscope in upsert["userKaleidxScopeList"]:
await self.data.score.put_user_kaleidx_scope(user_id, kaleidx_scope) await self.data.score.put_user_kaleidxscope(user_id, kaleidxscope)
return {"returnCode": 1, "apiName": "UpsertUserAllApi"} return {"returnCode": 1, "apiName": "UpsertUserAllApi"}

View File

@ -4,7 +4,6 @@ from core.config import CoreConfig
from titles.mai2.buddiesplus import Mai2BuddiesPlus from titles.mai2.buddiesplus import Mai2BuddiesPlus
from titles.mai2.const import Mai2Constants from titles.mai2.const import Mai2Constants
from titles.mai2.config import Mai2Config from titles.mai2.config import Mai2Config
from titles.mai2.schema.score import kaleidx_scope
class Mai2Prism(Mai2BuddiesPlus): class Mai2Prism(Mai2BuddiesPlus):
@ -50,18 +49,18 @@ class Mai2Prism(Mai2BuddiesPlus):
} }
async def handle_get_user_kaleidx_scope_api_request(self, data: Dict) -> Dict: 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":[]} return {"userId": data["userId"], "userKaleidxScopeList":[]}
kaleidx_scope_list = [] kaleidxscope_list = []
for kaleidx_scope_data in kaleidx_scope: for kaleidxscope_data in kaleidxscope:
tmp = kaleidx_scope_data._asdict() tmp = kaleidxscope_data._asdict()
tmp.pop("user") tmp.pop("user")
tmp.pop("id") tmp.pop("id")
kaleidx_scope_list.append(tmp) kaleidxscope_list.append(tmp)
return { return {
"userId": data["userId"], "userId": data["userId"],
"userKaleidxScopeList": kaleidx_scope_list "userKaleidxScopeList": kaleidxscope_list
} }

View File

@ -175,8 +175,8 @@ playlog_2p = Table(
mysql_charset="utf8mb4", mysql_charset="utf8mb4",
) )
kaleidx_scope = Table( kaleidxscope = Table(
"mai2_score_kaleidx_scope", "mai2_score_kaleidxscope",
metadata, metadata,
Column("id", Integer, primary_key=True, nullable=False), Column("id", Integer, primary_key=True, nullable=False),
Column( Column(
@ -481,21 +481,21 @@ class Mai2ScoreData(BaseData):
return None return None
return result.scalar() return result.scalar()
async def get_user_kaleidx_scope_list(self, user_id: int) -> Optional[List[Row]]: async def get_user_kaleidxscope_list(self, user_id: int) -> Optional[List[Row]]:
sql = kaleidx_scope.select(kaleidx_scope.c.user == user_id) sql = kaleidxscope.select(kaleidxscope.c.user == user_id)
result = await self.execute(sql) result = await self.execute(sql)
if result is None: if result is None:
return None return None
return result.fetchall() return result.fetchall()
async def put_user_kaleidx_scope(self, user_id: int, user_kaleidx_scope_data: Dict) -> Optional[int]: async def put_user_kaleidxscope(self, user_id: int, user_kaleidxscope_data: Dict) -> Optional[int]:
user_kaleidx_scope_data["user"] = user_id user_kaleidxscope_data["user"] = user_id
sql = insert(kaleidx_scope).values(**user_kaleidx_scope_data) 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) result = await self.execute(conflict)
if result is None: 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 None
return result.lastrowid return result.lastrowid