[object Object]

← back to Designer Wallcoverings

Fix kravet-master-loader: keep YARD-priced wallcoverings (Winfield Thybony foils), not just ROLL — track unit_of_measure

821c6a884d83af1e9878814dd784372d751db6a0 · 2026-06-25 16:46:53 -0700 · Steve

Files touched

Diff

commit 821c6a884d83af1e9878814dd784372d751db6a0
Author: Steve <steve@designerwallcoverings.com>
Date:   Thu Jun 25 16:46:53 2026 -0700

    Fix kravet-master-loader: keep YARD-priced wallcoverings (Winfield Thybony foils), not just ROLL — track unit_of_measure
---
 shopify/scripts/cadence/kravet-master-loader.py | 26 ++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/shopify/scripts/cadence/kravet-master-loader.py b/shopify/scripts/cadence/kravet-master-loader.py
index 2f59de7a..d12430c0 100644
--- a/shopify/scripts/cadence/kravet-master-loader.py
+++ b/shopify/scripts/cadence/kravet-master-loader.py
@@ -73,10 +73,15 @@ def main():
             print(f"  WARN sheet {src['sheet']!r} missing in {src['gdrive']}"); continue
         ws = wb[src['sheet']]
         it = ws.iter_rows(values_only=True); next(it, None)  # skip header
-        n_roll = 0
+        n_kept = 0
         for row in it:
-            unit = str(cell(row, src['c_unit']) or '')
-            if 'ROLL' not in unit.upper():
+            unit = str(cell(row, src['c_unit']) or '').strip()
+            unit_u = unit.upper()
+            # Keep ROLL-priced AND YARD-priced wallcoverings. Winfield Thybony
+            # foils/grasscloths (WDW/WHF/WNR/WPW/… ~2,500 SKUs) are legitimately
+            # sold per YARD; the old ROLL-only filter silently dropped them all,
+            # so they never got a price record and never published. (2026-06-25)
+            if not ('ROLL' in unit_u or 'YARD' in unit_u or unit_u == 'YD'):
                 continue
             sku = cell(row, src['c_item'])
             if not sku:
@@ -87,7 +92,7 @@ def main():
             retail = num(cell(row, src['c_retail']))
             if not (cost or retail):
                 continue
-            n_roll += 1
+            n_kept += 1
             prev = recs.get(sku)
             # prefer the row with a cost; then the higher-rank (newer) source
             better = (prev is None
@@ -96,12 +101,13 @@ def main():
             if better:
                 recs[sku] = {
                     'cost': cost, 'map': mp, 'retail': retail, 'rank': src['rank'],
+                    'unit': 'YARD' if 'YARD' in unit_u or unit_u == 'YD' else 'ROLL',
                     'brand': str(cell(row, src['c_brand']) or '')[:80],
                     'pattern': str(cell(row, src['c_pattern']) or '')[:120],
                     'color': str(cell(row, src['c_color']) or '')[:80],
                     'src': os.path.basename(src['gdrive'])[:60],
                 }
-        print(f"  [{src['sheet']}] ROLL rows scanned: {n_roll}")
+        print(f"  [{src['sheet']}] ROLL+YARD wallcovering rows scanned: {n_kept}")
 
     withcost = sum(1 for v in recs.values() if v['cost'])
     print(f"\nmaster ROLL SKUs: {len(recs)}  (with WHLS cost: {withcost}, retail-only: {len(recs)-withcost})")
@@ -121,17 +127,19 @@ def main():
     with open(tsv, 'w') as fh:
         for sku, v in recs.items():
             fh.write('\t'.join('' if x is None else str(x) for x in
-                     [sku, v['cost'], v['map'], v['retail'], v['brand'], v['pattern'], v['color'], v['src']]) + '\n')
+                     [sku, v['cost'], v['map'], v['retail'], v['brand'], v['pattern'], v['color'],
+                      v.get('unit') or 'ROLL', v['src']]) + '\n')
     ddl = """
     CREATE TABLE IF NOT EXISTS kravet_master_price (
       mfr_sku TEXT PRIMARY KEY, whls_cost NUMERIC, map_price NUMERIC, retail_price NUMERIC,
       brand TEXT, pattern TEXT, color TEXT, source TEXT, loaded_at TIMESTAMPTZ DEFAULT now());
+    ALTER TABLE kravet_master_price ADD COLUMN IF NOT EXISTS unit_of_measure TEXT;
     TRUNCATE kravet_master_price;
     CREATE TEMP TABLE _m(mfr_sku text, whls_cost numeric, map_price numeric, retail_price numeric,
-      brand text, pattern text, color text, source text);
+      brand text, pattern text, color text, unit_of_measure text, source text);
     \\copy _m FROM '%s'
-    INSERT INTO kravet_master_price(mfr_sku,whls_cost,map_price,retail_price,brand,pattern,color,source)
-      SELECT mfr_sku,whls_cost,map_price,retail_price,brand,pattern,color,source FROM _m
+    INSERT INTO kravet_master_price(mfr_sku,whls_cost,map_price,retail_price,brand,pattern,color,unit_of_measure,source)
+      SELECT mfr_sku,whls_cost,map_price,retail_price,brand,pattern,color,unit_of_measure,source FROM _m
       ON CONFLICT (mfr_sku) DO NOTHING;
     SELECT count(*) FROM kravet_master_price;
     """ % tsv

← 3a1c86b6 Scrub hardcoded Shopify theme token from 4 DW-Agents scripts  ·  back to Designer Wallcoverings  ·  feat(filter-topbar): ship-what-works — defaults to data-back 9ec87169 →