diff --git a/titles/idac/schema/rounds.py b/titles/idac/schema/rounds.py index 46c2e9f..1c208de 100644 --- a/titles/idac/schema/rounds.py +++ b/titles/idac/schema/rounds.py @@ -120,24 +120,24 @@ class IDACOnlineRounds(BaseData): self, round_id: int, version: int, round_data: Dict ) -> Optional[int]: - sql = select(round_details).where( - round_details.c.round_id_in_json == round_id - ) + sql = select(round_details).where(round_details.c.round_id_in_json == round_id) result = await self.execute(sql) - rid = result.fetchone() - if rid is None: - tmp = {} - tmp["round_id_in_json"] = round_id - tmp["name"] = round_data["round_event_nm"] - tmp["season"] = version - tmp["start_dt"] = datetime.datetime.fromtimestamp(round_data["start_dt"]) - tmp["end_dt"] = datetime.datetime.fromtimestamp(round_data["end_dt"]) + if result is None: + tmp = { + "round_id_in_json": round_id, + "name": round_data["round_event_nm"], + "season": version, + "start_dt": datetime.fromtimestamp(round_data["start_dt"]), + "end_dt": datetime.fromtimestamp(round_data["end_dt"]), + } sql = insert(round_details).values(**tmp) result = await self.execute(sql) return result.lastrowid + + rid = result.fetchone() return rid["id"] # TODO: get top five players of last round event for Boot/GetConfigData