idac: some bugfixes

This commit is contained in:
UncleJim 2024-05-04 02:46:33 +08:00
parent 8b7286ef18
commit 288560f7c6
2 changed files with 24 additions and 27 deletions

View File

@ -11,26 +11,26 @@ from core.data.schema import BaseData, metadata
from core.config import CoreConfig
round_details = Table(
"idac_round_info",
metadata,
"idac_round_info",
metadata,
Column("id", Integer, primary_key=True, nullable=False),
Column("round_id_in_json", Integer),
Column("name", String(64)),
Column("season", Integer),
Column("start_dt", TIMESTAMP, server_default=func.now()),
Column("end_dt", TIMESTAMP, server_default=func.now()),
Column("name", String(64)),
Column("season", Integer),
Column("start_dt", TIMESTAMP, server_default=func.now()),
Column("end_dt", TIMESTAMP, server_default=func.now()),
mysql_charset="utf8mb4",
)
round_info = Table(
"idac_user_round_info",
metadata,
"idac_user_round_info",
metadata,
Column("id", Integer, primary_key=True, nullable=False),
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")),
Column("round_id", ForeignKey("idac_round_info.id", ondelete="cascade", onupdate="cascade")),
Column("count", Integer),
Column("win", Integer),
Column("point", Integer),
Column("round_id", ForeignKey("idac_round_info.id", ondelete="cascade", onupdate="cascade")),
Column("count", Integer),
Column("win", Integer),
Column("point", Integer),
Column("play_dt", TIMESTAMP, server_default=func.now()),
UniqueConstraint("user", "round_id", name="idac_user_round_info_uk"),
mysql_charset="utf8mb4",
@ -57,7 +57,7 @@ class IDACOnlineRounds(BaseData):
)
)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchone()
@ -72,7 +72,7 @@ class IDACOnlineRounds(BaseData):
)
)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchone()
@ -86,7 +86,7 @@ class IDACOnlineRounds(BaseData):
sql = insert(round_info).values(**round_data)
conflict = sql.on_duplicate_key_update(**round_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warn(f"putround: Failed to update! aime_id: {aime_id}")
@ -100,13 +100,12 @@ class IDACOnlineRounds(BaseData):
sql = select(round_details).where(
round_details.c.round_id_in_json == round_id
)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
sql = insert(round_details).values(
round_details.c.round_id_in_json = round_id,
round_details.c.name = round_data["round_event_nm"],
round_details.c.season = 2, #default season 2
)
tmp["round_id_in_json"] = round_id
tmp["name"] = round_data["round_event_nm"]
tmp["season"] = 2 # default season 2
sql = insert(round_details).values(**tmp)
self.execute(sql)
return result.lastrowid
rid = result.fetchone()

View File

@ -61,10 +61,10 @@ class IDACSeason2(IDACBase):
)
# load the user configured round event (only one)
self.round_event_id = 0
self.round_event_id = 0
self.round_event = []
if self.game_config.round_event.enable:
round = self.game_config.round_event.enabled_round:
round = self.game_config.round_event.enabled_round
if round is not None:
if not os.path.exists(f"./titles/idac/data/rounds/season{self.version+1}/{round}.json"):
self.logger.warning(f"Round info {round} is enabled but json file does not exist!")
@ -76,6 +76,7 @@ class IDACSeason2(IDACBase):
tmp = json.load(f)
self.round_event_id = self.data.rounds._try_load_round_event(tmp["round_event_id"], tmp)
self.round_event.append(self._fix_dates(tmp))
self.logger.debug(f"Loaded round id {self.round_event_id}...")
# load the user configured battle gifts (only one)
self.battle_gift_event = None
@ -763,10 +764,7 @@ class IDACSeason2(IDACBase):
vs_info["course_select_priority"] = data.get("course_select_priority")
return vs_info
async def _update_round_info(
self, user_id: int, round_event_id: int, point: int, win: int
) -> Dict:
async def _update_round_info(self, user_id: int, round_event_id: int, point: int, win: int) -> Dict:
# get the round info data from database
round_info = []
ri = await self.data.rounds.get_round_info_by_id(user_id, round_event_id)