mirror of
https://gitea.tendokyu.moe/Hay1tsme/artemis.git
synced 2026-02-13 19:27:27 +08:00
add Kaleidx Scope Support
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from configparser import Interpolation
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from sqlalchemy import Column, Table, UniqueConstraint, and_
|
||||
@@ -174,6 +175,34 @@ playlog_2p = Table(
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
kaleidx_scope = Table(
|
||||
"mai2_score_kaleidx_scope",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column(
|
||||
"user",
|
||||
ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False,
|
||||
),
|
||||
Column("gateId", Integer),
|
||||
Column("isGateFound", Boolean),
|
||||
Column("isKeyFound", Boolean),
|
||||
Column("isClear", Boolean),
|
||||
Column("totalRestLife", Integer),
|
||||
Column("totalAchievement", Integer),
|
||||
Column("totalDeluxscore", Integer),
|
||||
Column("bestAchievement", Integer),
|
||||
Column("bestDeluxscore", Integer),
|
||||
Column("bestAchievementDate", String(25)),
|
||||
Column("bestDeluxscoreDate", String(25)),
|
||||
Column("playCount", Integer),
|
||||
Column("clearDate", String(25)),
|
||||
Column("lastPlayDate", String(25)),
|
||||
Column("isInfoWatched", Boolean),
|
||||
UniqueConstraint("user", "gateId", name="mai2_score_best_uk"),
|
||||
mysql_charset="utf8mb4"
|
||||
)
|
||||
|
||||
course = Table(
|
||||
"mai2_score_course",
|
||||
metadata,
|
||||
@@ -451,3 +480,22 @@ class Mai2ScoreData(BaseData):
|
||||
self.logger.warning(f"aime_id {aime_id} has no playlog ")
|
||||
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)
|
||||
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)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(**user_kaleidx_scope_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}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
Reference in New Issue
Block a user