← back to Dw Yolo Loop

scripts/kravet-cost/run-parallel.sh

32 lines

#!/usr/bin/env bash
# run-parallel.sh — fan the Kravet-family currency-check out, one process per brand,
# all brands concurrent. Needs AKEY (Algolia key) in the environment.
#   AKEY=<key> bash scripts/kravet-cost/run-parallel.sh
# Read-only: each worker only queries Algolia + reads the mirror, writes a per-brand CSV.
set -uo pipefail
cd "$(dirname "$0")/../.."
[ -z "${AKEY:-}" ] && { echo "FATAL: export AKEY=<algolia-key> first"; exit 1; }
mkdir -p data/kravet-cost

BRANDS=(
  "Kravet" "Brunschwig & Fils" "Clarke And Clarke" "Cole & Son" "Lee Jofa"
  "GP & J Baker" "Mulberry" "Threads" "Andrew Martin" "Baker Lifestyle"
  "Kravet Design" "Kravet Couture" "Lee Jofa Modern" "G P & J Baker"
)
echo "fanning ${#BRANDS[@]} brands in parallel…"
pids=()
for b in "${BRANDS[@]}"; do
  AKEY="$AKEY" node scripts/kravet-cost/currency-check.js "$b" >>"data/kravet-cost/run.log" 2>&1 &
  pids+=($!)
done
# wait for all, report
fail=0
for p in "${pids[@]}"; do wait "$p" || fail=$((fail+1)); done
echo "done — $fail worker(s) errored. per-brand CSVs in data/kravet-cost/, log: data/kravet-cost/run.log"
echo "=== summary ==="
for f in data/kravet-cost/currency-*.csv; do
  [ -f "$f" ] || continue
  tot=$(($(wc -l < "$f")-1))
  cur=$(grep -c ',CURRENT$' "$f" 2>/dev/null || echo 0)
  echo "  $(basename "$f"): $tot skus, $cur current"
done