From d612003f32458f8f33712cb4fc6160492e2b112a Mon Sep 17 00:00:00 2001 From: C <0xicl33n@gmail.com> Date: Sat, 11 Oct 2025 13:55:39 -0700 Subject: [PATCH] make middleware module (glue) --- src/glue.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/glue.py diff --git a/src/glue.py b/src/glue.py new file mode 100644 index 0000000..db53fc8 --- /dev/null +++ b/src/glue.py @@ -0,0 +1,32 @@ +import asyncio +import json +import get_sq_env +import aiosqlite + +import asquare +import db +import abricksetapi +from . throttler import GlobalThrottler + +async def do_review() -> bool: + result = await asquare.acat2id(LEGO_CAT_ID) + for item in result: + if not re.match(r".*\d{5}.*", item["name"]): + missing = [] + print(f"{item} is missing its set number!") + print(f"[@DEBUG] Upserting {item['id']} into REVIEW table") + item_sanitized = { + "sq_object": item["id"], + "set_name": item["name"], + "set_number": None, + "time_added": time + } + missing.append(item_sanitized) + for item in missing: + sq_item = await db.fetch(item["id"]) # + if item["id"] != sq_item["sq_object"]: + await db.upsert("REVIEW", item_sanitized, "sq_object") + print(f"[@DEBUG] Upserted {item['id']} into REVIEW table") + print(f"[@DEBUG] {item['id']} already in REVIEW table") + return True +