← back to Dw Yolo Loop

scripts/null-price-probe/null-price-livecheck.sh

20 lines

#!/bin/sh
# null-price-livecheck (c37) — READ-ONLY. Tests whether "ACTIVE products with
# null/0 price" is a real live-storefront problem or a Mac2-mirror artifact.
# VERDICT: ARTIFACT — the mirror's price column is only ~30% populated on ACTIVE
# (split-brain: not in the replicated set), and a live cross-check shows the
# "null-price" rows actually display $4.25 (the known GMC sample issue), not $0.
# So no DB-side price canary may trust shopify_products.price on Mac2. $0 local.
PSQL=/opt/homebrew/opt/postgresql@14/bin/psql
DB="postgresql:///dw_unified?host=/tmp"
echo "## ACTIVE price-column distribution (Mac2 mirror)"
$PSQL "$DB" -c "select count(*) active, count(*) filter (where price is null) price_null,
  count(*) filter (where price=4.25) eq425, count(*) filter (where price>4.25) real_price
  from shopify_products where status='ACTIVE';"
echo "## live cross-check: 5 mirror-null-price ACTIVE products -> live storefront variant prices"
$PSQL "$DB" -t -A -F'|' -c "select handle from shopify_products where status='ACTIVE' and price is null and handle>'' limit 5;" | while IFS= read -r h; do
  [ -z "$h" ] && continue
  curl -s --max-time 12 "https://www.designerwallcoverings.com/products/$h.json" \
   | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{try{const p=JSON.parse(s).product;console.log(process.argv[1],"-> LIVE:",(p.variants||[]).map(x=>x.price).join(", "))}catch(e){console.log(process.argv[1],"-> (no json)")}})' "$h"
done