From 005bf87df5ef22e7832e96acf50c2977c555341e Mon Sep 17 00:00:00 2001 From: C <0xicl33n@gmail.com> Date: Sat, 11 Oct 2025 11:39:29 -0700 Subject: [PATCH] add initial review testing for sql --- src/asquare.py | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/asquare.py b/src/asquare.py index 1059b98..2fdfd14 100644 --- a/src/asquare.py +++ b/src/asquare.py @@ -4,6 +4,12 @@ import json import asyncio import uuid import re +from time import time +import re +# we dont need no stinkin floats +time = int(time()) + +import db import get_sq_env @@ -114,15 +120,37 @@ async def acat2id(cat_id: str): return items +async def do_review() -> bool: + result = await 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 + async def test() -> None: task = asyncio.create_task(acat2id(LEGO_CAT_ID)) # type: ignore + await do_review() await asyncio.sleep(1) # Give the task some time to complete result = await task - print("OBJECTS IN LEGO CATEGORY:") - for item in result: - print(f"ID: {item['id']}, Name: {item['name']}") - # eturn + #print("OBJECTS IN LEGO CATEGORY:") + #print(f"ID: {item['id']}, Name: {item['name']}") + return True # pass @@ -134,6 +162,7 @@ async def test() -> None: if __name__ == "__main__": + print("Spooling up..") print(f"@[DEBUG] ENV:\t{ENVIRONMENT}") print(f"@[DEBUG] CATID:\t{LEGO_CAT_ID}") asyncio.run(test())