From fae6b77403926ed0b7e83e60022579effc6a4597 Mon Sep 17 00:00:00 2001 From: Hay1tsme Date: Fri, 3 Mar 2023 15:03:57 -0500 Subject: [PATCH] core: TESTING fix for get_machine --- core/data/schema/arcade.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/core/data/schema/arcade.py b/core/data/schema/arcade.py index 117c3fe..921e5b5 100644 --- a/core/data/schema/arcade.py +++ b/core/data/schema/arcade.py @@ -50,9 +50,20 @@ arcade_owner = Table( class ArcadeData(BaseData): def get_machine(self, serial: str = None, id: int = None) -> Optional[Dict]: if serial is not None: - sql = machine.select(machine.c.serial == serial) + serial = serial.replace("-", "") + if len(serial) == 11: + sql = machine.select(machine.c.serial.like(f"{serial}%")) + + elif len(serial) == 15: + sql = machine.select(machine.c.serial == serial) + + else: + self.logger.error(f"{__name__ }: Malformed serial {serial}") + return None + elif id is not None: sql = machine.select(machine.c.id == id) + else: self.logger.error(f"{__name__ }: Need either serial or ID to look up!") return None @@ -110,4 +121,4 @@ class ArcadeData(BaseData): return result.lastrowid def generate_keychip_serial(self, platform_id: int) -> str: - pass \ No newline at end of file + pass