[object Object]

← back to Designer Wallcoverings

kravet: materialize DWKK roll prices into snapshot for whole-line MAP canary coverage (TK-10014)

eb55c93d8eab3b084b81758b958643f41a8dae62 · 2026-07-28 13:25:52 -0700 · Steve

refresh-dwkk-roll-prices.sh bulk-exports current DWKK roll-variant prices into
dw_unified.dwkk_roll_price_snapshot. dw-map-auditor now coalesces this over the
mirror's sample-only sp.price -> canary price-coverage 1,929 -> 11,893 of 13,434.

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

Files touched

Diff

commit eb55c93d8eab3b084b81758b958643f41a8dae62
Author: Steve <steve@designerwallcoverings.com>
Date:   Tue Jul 28 13:25:52 2026 -0700

    kravet: materialize DWKK roll prices into snapshot for whole-line MAP canary coverage (TK-10014)
    
    refresh-dwkk-roll-prices.sh bulk-exports current DWKK roll-variant prices into
    dw_unified.dwkk_roll_price_snapshot. dw-map-auditor now coalesces this over the
    mirror's sample-only sp.price -> canary price-coverage 1,929 -> 11,893 of 13,434.
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
 shopify/scripts/refresh-dwkk-roll-prices.sh | 60 +++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/shopify/scripts/refresh-dwkk-roll-prices.sh b/shopify/scripts/refresh-dwkk-roll-prices.sh
new file mode 100755
index 00000000..27a6c652
--- /dev/null
+++ b/shopify/scripts/refresh-dwkk-roll-prices.sh
@@ -0,0 +1,60 @@
+#!/usr/bin/env bash
+# refresh-dwkk-roll-prices.sh (TK-10014, 2026-07-28)
+# Materializes CURRENT DWKK roll-variant prices into dw_unified.dwkk_roll_price_snapshot,
+# so the dw-map-auditor canary can price-check the WHOLE line (the mirror's shopify_products.price
+# stores the $4.25 sample for ~88% of DWKK, not the roll). Bulk-exports from Shopify (one op, ~2-3 min).
+# Run in the same cadence as gen-kravet-worklist-from-ftp.sh (read-only Shopify + local upsert; unattended-safe).
+set -uo pipefail
+TOK=$(grep '^SHOPIFY_ADMIN_TOKEN=' ~/Projects/secrets-manager/.env | cut -d= -f2- | tr -d '"')
+SHOP=designer-laboratory-sandbox.myshopify.com
+GQL="https://$SHOP/admin/api/2024-10/graphql.json"
+hdr=(-H "X-Shopify-Access-Token: $TOK" -H "Content-Type: application/json")
+
+echo "1) start bulk export of DWKK products+variant prices…"
+curl -s "${hdr[@]}" "$GQL" -d @- >/dev/null <<'JSON'
+{"query":"mutation { bulkOperationRunQuery(query: \"{ products(query: \\\"sku:DWKK*\\\") { edges { node { id handle status variants { edges { node { id title price } } } } } } }\") { bulkOperation { id status } userErrors { field message } } }"}
+JSON
+
+echo "2) poll…"
+url=""
+for i in $(seq 1 60); do
+  sleep 5
+  poll=$(curl -s "${hdr[@]}" "$GQL" -d '{"query":"{ currentBulkOperation { status url objectCount } }"}')
+  st=$(echo "$poll" | python3 -c 'import sys,json;print(json.load(sys.stdin)["data"]["currentBulkOperation"]["status"])')
+  echo "   [$i] $st"
+  if [ "$st" = "COMPLETED" ]; then url=$(echo "$poll" | python3 -c 'import sys,json;print(json.load(sys.stdin)["data"]["currentBulkOperation"]["url"] or "")'); break; fi
+  [ "$st" = "FAILED" ] && { echo "BULK FAILED"; exit 1; }
+done
+[ -z "$url" ] && { echo "no url"; exit 1; }
+
+echo "3) download + parse roll (non-sample) prices…"
+curl -s "$url" -o /tmp/dwkk_rollprice_bulk.jsonl
+python3 - <<'PY' > /tmp/dwkk_rollprice.tsv
+import json
+ph={}; roll={}
+for line in open('/tmp/dwkk_rollprice_bulk.jsonl'):
+    o=json.loads(line)
+    if 'handle' in o:
+        if o.get('status')=='ACTIVE': ph[o['id']]=o['handle'].upper()
+    elif 'price' in o and o.get('title') is not None:
+        if 'sample' in (o.get('title') or '').lower(): continue
+        pid=o.get('__parentId')
+        if pid: roll[pid]=(o['price'], o['id'])
+for pid,h in ph.items():
+    if pid in roll:
+        price,vid=roll[pid]
+        print(f"{h}\t{price}\t{vid}")
+PY
+n=$(wc -l < /tmp/dwkk_rollprice.tsv | tr -d ' ')
+echo "   parsed $n roll prices"
+
+echo "4) upsert into dwkk_roll_price_snapshot…"
+psql "host=/tmp dbname=dw_unified" <<SQL 2>&1
+create temp table _stage(dw_sku text, roll_price numeric, variant_id text);
+\copy _stage from '/tmp/dwkk_rollprice.tsv' with (format csv, delimiter E'\t');
+insert into dwkk_roll_price_snapshot(dw_sku, roll_price, variant_id, snapshot_at)
+select dw_sku, roll_price, variant_id, now() from _stage
+on conflict (dw_sku) do update set roll_price=excluded.roll_price, variant_id=excluded.variant_id, snapshot_at=now();
+select count(*) as snapshot_rows from dwkk_roll_price_snapshot;
+SQL
+echo "done."

← 42a8a5cb Hide native 'You may also like' so the CLIP 'More Wallcoveri  ·  back to Designer Wallcoverings  ·  auto-save: 2026-07-28T13:30:51 (9 files) — DW-Programming/DW d96acfe8 →