mirror of
https://gitea.tendokyu.moe/Hay1tsme/artemis.git
synced 2026-02-13 03:07:29 +08:00
database support for prism
kaleidxScope Key Condition store
This commit is contained in:
@@ -71,6 +71,17 @@ cards = Table(
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
kaleidxscope_condition = Table(
|
||||
"mai2_static_kaleidxscope_condition",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("conditionId", Integer),
|
||||
Column("conditionName", String(255)),
|
||||
Column("songId", Integer),
|
||||
Column("songName", String(255)),
|
||||
UniqueConstraint("conditionId", "conditionName", "songId", "songName", name="mai2_static_kaleidxscope_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
class Mai2StaticData(BaseData):
|
||||
async def put_game_event(
|
||||
@@ -264,3 +275,35 @@ class Mai2StaticData(BaseData):
|
||||
result = await self.execute(event.update(event.c.id == table_id).values(enabled=is_enable, startDate = start_date))
|
||||
if not result:
|
||||
self.logger.error(f"Failed to update event {table_id} - {is_enable} {start_date}")
|
||||
|
||||
# new in prism
|
||||
async def put_kaleidxscope_condition(
|
||||
self,
|
||||
condition_id: int,
|
||||
condition_name: str,
|
||||
music_id: int,
|
||||
music_name: str
|
||||
) -> Optional[int]:
|
||||
sql = insert(kaleidxscope_condition).values(
|
||||
conditionId = condition_id,
|
||||
conditionName = condition_name,
|
||||
songId = music_id,
|
||||
songName = music_name,
|
||||
)
|
||||
|
||||
|
||||
conflict = sql.on_duplicate_key_update(conditionName=condition_name, songName=music_name)
|
||||
|
||||
result = await self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.warning(
|
||||
f"put_kaleidxscope_condition: Failed to insert kaleidxScope Key Condition! conditionID {condition_id} songId {music_id}"
|
||||
)
|
||||
return result.lastrowid
|
||||
|
||||
async def get_kaleidxscope_condition(self, condition_id: int) -> None:
|
||||
sql = kaleidxscope_condition.select(kaleidxscope_condition.c.conditionId == condition_id)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
Reference in New Issue
Block a user