← back to Nationalrealestate
scripts/run-firm-enrich.sh
16 lines
#!/bin/zsh
# TK-10687 incremental firm-phone enrichment (firm-phone-first, $0 local). Chips away at the ~21.7k
# CA phoneless firms (highest active-broker count first) so every affiliated active broker becomes
# callable via the firm-phone fallback. Bounded per run (--limit ≤ 500). Writes to the LOCAL usre DB
# (staging); the Kamatera prod sync stays Steve-gated. Then records coverage for the tracker.
export PATH="/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin"
cd "$HOME/Projects/nationalrealestate" || exit 1
LOG="$HOME/Projects/nationalrealestate/data/firm-enrich.log"
LIMIT="${FIRM_ENRICH_LIMIT:-400}"
echo "[$(date '+%F %T')] enrich start (limit $LIMIT)" >> "$LOG"
# Ollama (local model) must be up; skip cleanly if not (never spend, never error the cron).
if ! curl -s -o /dev/null http://localhost:11434/api/tags; then echo "[$(date '+%F %T')] SKIP — Ollama down" >> "$LOG"; exit 0; fi
/opt/homebrew/bin/node scripts/enrich-firm-contacts.mjs --limit "$LIMIT" --apply >> "$LOG" 2>&1
/opt/homebrew/bin/node scripts/firm-phone-coverage.mjs >> "$LOG" 2>&1
echo "[$(date '+%F %T')] enrich done" >> "$LOG"