← back to Re Flyer Aggregator
scripts/dtt-cron.sh
36 lines
#!/bin/bash
# TK-10708 Daily "be first to a closed deal" pipeline (launchd com.steve.dtt-import).
export PATH="/opt/homebrew/bin:/opt/homebrew/opt/postgresql@14/bin:/usr/bin:/bin:/usr/sbin:/sbin"
cd "$(dirname "$0")/.." || exit 1
LOG="data/dtt-cron.log"; mkdir -p data out
echo "=== $(date '+%Y-%m-%d %H:%M:%S') daily run ===" >> "$LOG"
# TK-11856 rc-propagation (exit-code ONLY, no behavior change): every step still runs in order even
# if an earlier one fails (no set -e, exactly as before); we only REMEMBER the first nonzero rc of a
# step (incl. the George digest send + both Kamatera pushes) and exit with it at the end, instead of
# the closing echo's 0. Undo: git revert.
FIRST_RC=0
note_rc() { r=$?; if [ "$r" -ne 0 ]; then echo "--- step '$1' exit $r ---" >> "$LOG"; if [ "$FIRST_RC" -eq 0 ]; then FIRST_RC=$r; fi; fi; }
# 1) FREE broad same-day feed: CRE trade-press closed deals (private + public)
node scripts/cre-news-monitor.mjs >> "$LOG" 2>&1
note_rc cre-news-monitor.mjs
# 2) FREE early-signal: SEC EDGAR CRE acquisition 8-Ks (biggest public deals)
node scripts/edgar-cre-monitor.mjs --days 14 >> "$LOG" 2>&1
note_rc edgar-cre-monitor.mjs
# 3) DTT sales import (free assessor source; frozen until a fresh feed is added)
node scripts/ingest-la-sales.mjs >> "$LOG" 2>&1
note_rc ingest-la-sales.mjs
# 4) Rebuild flyers.agentabrams.com static site from the aggregated deals
node scripts/build-flyers-site.mjs >> "$LOG" 2>&1
note_rc build-flyers-site.mjs
# 5) Email the morning's NEW closed deals to Steve via George (only if there are any)
bash scripts/email-digest.sh >> "$LOG" 2>&1
note_rc email-digest.sh
# 6) Push the fresh viewer data to the LIVE Kamatera re-flyers-viewer (/search + /)
bash scripts/sync-viewer-data-to-kamatera.sh >> "$LOG" 2>&1
note_rc sync-viewer-data-to-kamatera.sh
# 7) Refresh the deal-assets viewer's DB snapshot on Kamatera (re-flyers-deals / dealassets)
bash scripts/sync-deals-to-kamatera.sh >> "$LOG" 2>&1
note_rc sync-deals-to-kamatera.sh
echo "--- exit $FIRST_RC ---" >> "$LOG"
exit "$FIRST_RC"