FIXXXXX
This commit is contained in:
1 parent
30b4b26c9e
commit
535826fce6
2 files changed
+18
-8
No files matched your search
+10
-4
@@ -16,11 +16,12 @@ Throttler = throttler.GlobalThrottler
|
||||
LEGO_CAT_ID = get_sq_env.LEGO_CAT_ID
|
||||
|
||||
|
||||
async def enrich_single_item(item_id: str, logger=None) -> bool:
|
||||
async def enrich_single_item(item_id: str, item_data: dict = None, logger=None) -> bool:
|
||||
r"""
|
||||
Enrich a single Square catalog item with Brickset data.
|
||||
|
||||
Flow:
|
||||
1. Get item details from Square (by item_id)
|
||||
1. Get item details from Square (by item_id) - skip if item_data provided
|
||||
2. Extract 5-digit set number from name (regex \d{5})
|
||||
3. Fetch Brickset data (with throttling)
|
||||
4. Update Square item with enriched data
|
||||
@@ -28,6 +29,7 @@ async def enrich_single_item(item_id: str, logger=None) -> bool:
|
||||
|
||||
Args:
|
||||
item_id: Square catalog item ID
|
||||
item_data: Optional pre-fetched item data (avoids redundant API call)
|
||||
logger: Optional logger instance for debug output
|
||||
|
||||
Returns:
|
||||
@@ -39,8 +41,12 @@ async def enrich_single_item(item_id: str, logger=None) -> bool:
|
||||
else:
|
||||
print(f"[@DEBUG] Starting enrichment for item {item_id}")
|
||||
|
||||
# Get item details from Square
|
||||
item = await asquare.get_item_by_id(item_id)
|
||||
# Get item details from Square (only if not already provided)
|
||||
if item_data is None:
|
||||
item = await asquare.get_item_by_id(item_id)
|
||||
else:
|
||||
item = item_data
|
||||
|
||||
item_name = item.get("name", "")
|
||||
|
||||
if logger:
|
||||
|
||||
Reference in new issue
Block a user