[object Object]

← back to Designer Wallcoverings

Add --fill-catalog: backfill single-roll W/L from thibaut_catalog by dw_sku

1e1c3b222f0afa050e47f670817b37c8352ca194 · 2026-07-06 14:15:52 -0700 · Steve

- joins on dw_sku (not shopify_product_id) to reach the 800 length-missing products
  the old backfill couldn't see; fills single-roll W/L then double-roll dims+copy
- dry-run: dims-exceptions 827 -> 61; 766 more products fillable; 3105 writes queued
- min/step writes now 0 (confirms first live run landed)
- remaining 61 have no confirmed length in catalog -> need a Thibaut scrape

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Files touched

Diff

commit 1e1c3b222f0afa050e47f670817b37c8352ca194
Author: Steve <steve@designerwallcoverings.com>
Date:   Mon Jul 6 14:15:52 2026 -0700

    Add --fill-catalog: backfill single-roll W/L from thibaut_catalog by dw_sku
    
    - joins on dw_sku (not shopify_product_id) to reach the 800 length-missing products
      the old backfill couldn't see; fills single-roll W/L then double-roll dims+copy
    - dry-run: dims-exceptions 827 -> 61; 766 more products fillable; 3105 writes queued
    - min/step writes now 0 (confirms first live run landed)
    - remaining 61 have no confirmed length in catalog -> need a Thibaut scrape
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
 shopify/scripts/set-dwtt-doubleroll-min-dims.py | 31 +++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/shopify/scripts/set-dwtt-doubleroll-min-dims.py b/shopify/scripts/set-dwtt-doubleroll-min-dims.py
index 00ae0336..22be06ee 100644
--- a/shopify/scripts/set-dwtt-doubleroll-min-dims.py
+++ b/shopify/scripts/set-dwtt-doubleroll-min-dims.py
@@ -49,6 +49,8 @@ SHOP  = os.environ.get("SHOPIFY_SHOP", "designer-laboratory-sandbox.myshopify.co
 GQL   = f"https://{SHOP}/admin/api/2024-10/graphql.json"
 LIVE  = "--live" in sys.argv
 MIN_ONLY = "--min-only" in sys.argv   # queue ONLY the min/step writes (hold dims+copy)
+FILL_CATALOG = "--fill-catalog" in sys.argv  # backfill single-roll W/L from thibaut_catalog by dw_sku
+PGURI = "postgresql:///dw_unified?host=/tmp"
 HERE  = os.path.dirname(os.path.abspath(__file__))
 BEFORE = os.path.join(HERE, "audits", "dwtt-doubleroll-before-state.jsonl")
 os.makedirs(os.path.dirname(BEFORE), exist_ok=True)
@@ -119,7 +121,26 @@ def chunked(lst, n):
     for i in range(0, len(lst), n):
         yield lst[i:i+n]
 
+def load_catalog():
+    """dw_sku -> (single_roll_width, single_roll_length) from thibaut_catalog.
+    PDP-confirmed = specs->>'width'/'single_roll_length' first, else width/roll_length."""
+    import subprocess
+    q = ("SELECT dw_sku, COALESCE(NULLIF(specs->>'width',''),width,''), "
+         "COALESCE(NULLIF(specs->>'single_roll_length',''),roll_length,'') "
+         "FROM thibaut_catalog WHERE COALESCE(dw_sku,'')<>''")
+    out = subprocess.run(["psql", PGURI, "-tA", "-F", "\t", "-c", q],
+                         capture_output=True, text=True, check=True).stdout
+    m = {}
+    for line in out.splitlines():
+        parts = line.split("\t")
+        if len(parts) == 3 and parts[0]:
+            m[parts[0]] = (parts[1].strip(), parts[2].strip())
+    return m
+
 def main():
+    catalog = load_catalog() if FILL_CATALOG else {}
+    if FILL_CATALOG:
+        print(f">>> --fill-catalog: loaded {len(catalog)} dw_sku dims from thibaut_catalog.")
     # 1) page every ACTIVE/DRAFT Thibaut product
     prods, cursor = [], None
     while True:
@@ -167,6 +188,16 @@ def main():
         # ---- double-roll dims + copy (guarded: needs confirmed single-roll W+L) ----
         w = (p["width"] or {}).get("value")
         L = (p["length"] or {}).get("value")
+        # catalog fallback: fill single-roll W/L from thibaut_catalog by dw_sku
+        if FILL_CATALOG and (not w or not L):
+            dwsku = re.sub(r"-(Roll|Sample)$", "", roll_vars[0]["sku"] or "")
+            cw, cl = catalog.get(dwsku, ("", ""))
+            if not w and cw:
+                w = cw
+                inputs.append({"ownerId":pid,"namespace":"global","key":"width","type":"single_line_text_field","value":cw}); dim_writes+=1
+            if not L and cl:
+                L = cl
+                inputs.append({"ownerId":pid,"namespace":"global","key":"length","type":"single_line_text_field","value":cl}); dim_writes+=1
         pl = parse_len(L)
         if not (w and pl and pl[0] > 0):   # 0 yd / 0.00 m is not a real dimension
             dims_exceptions.append({"handle": p["handle"], "sku": roll_vars[0]["sku"],

← 0d777f6f Carl Robinson: add 'Wallcovering' type descriptor to titles  ·  back to Designer Wallcoverings  ·  DWTT double-roll PHASE 2 live: 3105 metafields, 0 errors (ca 21c4a09b →