From f225b732f2eaeffc21e6dc768b5013f3e8f0f000 Mon Sep 17 00:00:00 2001 From: UncleJim Date: Sat, 6 Jan 2024 14:04:47 +0000 Subject: [PATCH] implement new vs_info saving method --- titles/idac/schema/item.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/titles/idac/schema/item.py b/titles/idac/schema/item.py index d60f620..68d1729 100644 --- a/titles/idac/schema/item.py +++ b/titles/idac/schema/item.py @@ -780,13 +780,7 @@ class IDACItemData(BaseData): result = self.execute(sql) if result is None: return None - - d, a = {}, [] - for row in result: - for column, value in row.items(): - d = {**d, **{column: value}} - a.append(d) - return a + return result.fetchall() def get_stamps(self, aime_id: int) -> Optional[List[Row]]: sql = select(stamp).where( @@ -988,7 +982,7 @@ class IDACItemData(BaseData): vs_info_data["user"] = aime_id vs_info_data["battle_mode"] = battle_mode - sql = insert(vs_info_new).values(**vs_info_data) + sql = insert(vs_info).values(**vs_info_data) conflict = sql.on_duplicate_key_update(**vs_info_data) result = self.execute(conflict) @@ -997,6 +991,19 @@ class IDACItemData(BaseData): return None return result.lastrowid + def put_vs_course_info(self, aime_id: int, battle_mode: int, course_info_data: Dict) -> Optional[int]: + course_info_data["user"] = aime_id + course_info_data["battle_mode"] = battle_mode + + sql = insert(vs_course_info).values(**course_info_data) + conflict = sql.on_duplicate_key_update(**course_info_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_vs_course_info: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + def put_stamp( self, aime_id: int, stamp_data: Dict ) -> Optional[int]: