From 262155f83f67384322effaf95fbd72d2de8b4339 Mon Sep 17 00:00:00 2001 From: Hay1tsme Date: Mon, 4 Dec 2023 11:40:20 -0500 Subject: [PATCH] ongeki: fix handle_upsert_client_setting_api_request --- titles/ongeki/base.py | 4 +++- titles/ongeki/schema/static.py | 9 ++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/titles/ongeki/base.py b/titles/ongeki/base.py index 7cf07be..596fb22 100644 --- a/titles/ongeki/base.py +++ b/titles/ongeki/base.py @@ -268,7 +268,9 @@ class OngekiBase: client_id = data["clientId"] client_setting_data = data["clientSetting"] - self.data.static.put_client_setting_data(client_id, client_setting_data) + cab = self.data.arcade.get_machine(client_id) + if cab is not None: + self.data.static.put_client_setting_data(cab['id'], client_setting_data) return {"returnCode": 1, "apiName": "UpsertClientSettingApi"} def handle_upsert_client_testmode_api_request(self, data: Dict) -> Dict: diff --git a/titles/ongeki/schema/static.py b/titles/ongeki/schema/static.py index 38d5ee5..695d39a 100644 --- a/titles/ongeki/schema/static.py +++ b/titles/ongeki/schema/static.py @@ -486,13 +486,12 @@ class OngekiStaticData(BaseData): return None return result.lastrowid - def put_client_setting_data(self, client_id: str, client_setting_data: Dict) -> Optional[List[Dict]]: - sql = insert(machine).values(data=client_setting_data) - conflict = sql.on_duplicate_key_update(serial=client_id) + def put_client_setting_data(self, machine_id: int, client_setting_data: Dict) -> Optional[List[Dict]]: + sql = machine.update(machine.c.id == machine_id).values(data=client_setting_data) - result = self.execute(conflict) + result = self.execute(sql) if result is None: - self.logger.warning(f"clientId: {client_id} Failed to update ClientSetting data"), + self.logger.warning(f"machine_id: {machine_id} Failed to update ClientSetting data"), return None return result.lastrowid