← back to Dw Catalog 404 Audit
audit-404.sh
25 lines
#!/bin/bash
# DW catalog-integrity 404 audit (READ-ONLY). dw_unified mirror + public storefront HEAD/GET only.
# No writes. Author: vp-dw-commerce. See dw-catalog-404-integrity.md memo.
set -euo pipefail
DB=dw_unified
OUT="${1:-/tmp/dw404}"; mkdir -p "$OUT"
echo "[1] scope: ACTIVE rows + handle quality"
psql -d "$DB" -At -c "
SELECT 'active_total',count(*) FROM shopify_products WHERE status='ACTIVE'
UNION ALL SELECT 'handle_null',count(*) FROM shopify_products WHERE status='ACTIVE' AND handle IS NULL
UNION ALL SELECT 'handle_empty',count(*) FROM shopify_products WHERE status='ACTIVE' AND handle=''
UNION ALL SELECT 'handle_eq_lower_dwsku',count(*) FROM shopify_products WHERE status='ACTIVE' AND handle=lower(dw_sku)
UNION ALL SELECT 'handle_suffix_-handle',count(*) FROM shopify_products WHERE status='ACTIVE' AND handle ~ '-handle\$'
UNION ALL SELECT 'handle_suffix_-sample',count(*) FROM shopify_products WHERE status='ACTIVE' AND handle ~ '-sample\$';"
echo "[2] HTTP sample of REAL handles (low concurrency to avoid 429)"
N="${2:-400}"
psql -d "$DB" -At -c "SELECT handle FROM shopify_products WHERE status='ACTIVE' AND handle IS NOT NULL AND handle<>'' ORDER BY random() LIMIT $N;" > "$OUT/sample_handles.txt"
: > "$OUT/results.txt"
while read -r h; do
sleep 0.5
code=$(curl -s -o /dev/null -w "%{http_code}" -L --max-time 25 -A "Mozilla/5.0 DW-audit" "https://designerwallcoverings.com/products/$h")
echo "$code $h" >> "$OUT/results.txt"
done < "$OUT/sample_handles.txt"
echo "results:"; awk '{print $1}' "$OUT/results.txt" | sort | uniq -c | sort -rn