cleanup resolved missing skus

This commit is contained in:
Claude Agent
2026-03-25 22:29:33 +00:00
parent a659f3bafb
commit f2bf6805b4
2 changed files with 24 additions and 0 deletions

View File

@@ -240,6 +240,23 @@ async def track_missing_sku(sku: str, product_name: str = "",
await db.close()
async def resolve_missing_skus_batch(skus: set):
"""Mark multiple missing SKUs as resolved (they now have mappings)."""
if not skus:
return 0
db = await get_sqlite()
try:
placeholders = ",".join("?" for _ in skus)
cursor = await db.execute(f"""
UPDATE missing_skus SET resolved = 1, resolved_at = datetime('now')
WHERE sku IN ({placeholders}) AND resolved = 0
""", list(skus))
await db.commit()
return cursor.rowcount
finally:
await db.close()
async def resolve_missing_sku(sku: str):
"""Mark a missing SKU as resolved."""
db = await get_sqlite()

View File

@@ -410,6 +410,13 @@ async def run_sync(id_pol: int = None, id_sectie: int = None, run_id: str = None
customers=json.dumps(ctx.get("customers", [])) if ctx.get("customers") else None,
)
# Auto-resolve missing SKUs that now have mappings
resolved_skus = validation["mapped"] | validation["direct"]
if resolved_skus:
resolved_count = await sqlite_service.resolve_missing_skus_batch(resolved_skus)
if resolved_count:
_log_line(run_id, f"Auto-resolved {resolved_count} previously missing SKUs")
# Step 2d: Pre-validate prices for importable articles
if id_pol and (truly_importable or already_in_roa):
_update_progress("validation", "Validating prices...", 0, len(truly_importable))