← back to Commercialrealestate
scripts/run-condos-report.sh
33 lines
#!/bin/zsh
# Weekly "Unwarrantable Condos" report -> separate email to steve-office + steve-personal via George.
# Wired to launchd com.steve.cre-condos-report (Mon 06:30 America/Los_Angeles, after the weekly CRE refresh).
# Scope: fha_expired condos only (lapsed FHA approval = financing-discount plays). See scripts/condos-report.js.
# Cadence is WEEKLY (not daily) because the Redfin condo re-scrape is a ~$3.20 Browserbase run and the
# unwarrantable set barely moves day-to-day; a weekly refresh keeps it fresh at ~$13/mo.
export PATH="/usr/local/bin:/opt/homebrew/bin:$HOME/.npm-global/bin:$HOME/.claude/local:$PATH"
export NODE_PATH="$HOME/.claude/skills/browserbase/node_modules"
cd "$HOME/Projects/commercialrealestate" || exit 1
LOG=/tmp/cre-condos-report.log
echo "===== condos run $(date) =====" >> "$LOG"
# 1) Refresh + re-classify LA County condos from Redfin (hard-capped ~$3.20). Non-fatal: if Browserbase is
# down we still build + email off the last classified snapshot so the report always goes out.
/opt/homebrew/bin/node scripts/fetch-condos-redfin.js >> "$LOG" 2>&1 || echo "fetch-condos-redfin failed (continuing on last snapshot)" >> "$LOG"
# 2) Build the unwarrantable-condos HTML (fha_expired only).
REPORT_DATE="$(date +%Y-%m-%d)" /opt/homebrew/bin/node scripts/condos-report.js > data/condos-report.html 2>> "$LOG"
# 3) Email the report as-is (separate from the multifamily CRE Top-10).
TODAY="$(date +%Y-%m-%d)"
NEXP=$(/opt/homebrew/bin/node -e 'const r=JSON.parse(require("fs").readFileSync("data/condos-redfin.json","utf8"));const a=Array.isArray(r)?r:(r.condos||r.listings||r.results||Object.values(r).find(Array.isArray)||[]);process.stdout.write(String(a.filter(c=>c.warrantable_status==="fha_expired").length))' 2>/dev/null)
PROMPT="Read /Users/macstudio3/Projects/commercialrealestate/data/condos-report.html and send its FULL contents as the HTML body of an email using the mcp__george__gmail_send tool with account 'steve-office' to 'steve@designerwallcoverings.com, steveabramsdesigns@gmail.com'. Subject: 'Unwarrantable Condos - ${NEXP} FHA-lapsed plays ($TODAY)'. Send the HTML exactly as-is; do not summarize, truncate, or modify it. Sending that one email is the ONLY action to take."
env -u ANTHROPIC_API_KEY -u ANTHROPIC_AUTH_TOKEN "$HOME/.npm-global/bin/claude" -p "$PROMPT" \
--allowedTools "Read" "mcp__george__gmail_send" \
--dangerously-skip-permissions >> "$LOG" 2>&1
# 4) Persist data + report.
git -c user.email=steve@designerwallcoverings.com -c user.name="Steve" add -A >> "$LOG" 2>&1
git -c user.email=steve@designerwallcoverings.com -c user.name="Steve" commit -q -m "weekly unwarrantable-condos report $(date +%Y-%m-%d)" >> "$LOG" 2>&1 || echo "nothing to commit" >> "$LOG"
echo "===== done $(date) =====" >> "$LOG"