From d5c68a624fab8705a4f1b58e82b695c1a66393b3 Mon Sep 17 00:00:00 2001 From: Hay1tsme Date: Tue, 16 Sep 2025 18:11:52 -0400 Subject: [PATCH] billing: bomb out early if we have unsent logs to avoid duplicating work that's never used --- core/allnet.py | 8 +++----- core/data/schema/arcade.py | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/core/allnet.py b/core/allnet.py index 94b34ab..43a2478 100644 --- a/core/allnet.py +++ b/core/allnet.py @@ -805,8 +805,9 @@ class BillingServlet: ) if req.traceleft > 0: - self.logger.warning(f"{req.traceleft} unsent tracelogs") - + self.logger.info(f"Requesting 20 more of {req.traceleft} unsent tracelogs") + return PlainTextResponse("result=6&waittime=0&linelimit=20\r\n") + playlimit = req.playlimit while req.playcnt > playlimit: playlimit += 1024 @@ -825,9 +826,6 @@ class BillingServlet: resp_str = urllib.parse.unquote(urllib.parse.urlencode(vars(resp))) + "\r\n" self.logger.debug(f"response {vars(resp)}") - if req.traceleft > 0: # TODO: should probably move this up so we don't do a ton of work that doesn't get used - self.logger.info(f"Requesting 20 more of {req.traceleft} unsent tracelogs") - return PlainTextResponse("result=6&waittime=0&linelimit=20\r\n") return PlainTextResponse(resp_str) diff --git a/core/data/schema/arcade.py b/core/data/schema/arcade.py index d1790b8..4787a5b 100644 --- a/core/data/schema/arcade.py +++ b/core/data/schema/arcade.py @@ -433,7 +433,7 @@ class ArcadeData(BaseData): self.logger.error(f"Failed to add billing charge for machine {machine_id}!") return None return result.lastrowid - + async def billing_get_last_charge(self, machine_id: int, game_id: str) -> Optional[Row]: result = await self.execute(billing_charge.select( and_(billing_charge.c.machine == machine_id, billing_charge.c.game_id == game_id) @@ -511,7 +511,7 @@ class ArcadeData(BaseData): if result is None: self.logger.error(f"Failed to add playcount for machine {machine_id} running {game_id}") - + async def billing_get_playcount_3mo(self, machine_id: int, game_id: str) -> Optional[List[Row]]: result = await self.execute(billing_playct.select(and_( billing_playct.c.machine == machine_id,