mirror of
https://github.com/computerim/impactflow-discovery.git
synced 2026-08-27 07:30:35 +00:00
Add weekly coaching check-in cron script
scripts/run-weekly-checkins.sh reads the admin API key from .env and POSTs the Phase 3 batch endpoint (/discovery/coaching/run); a weekly host crontab entry (Mon 08:00) invokes it. Running weekly services all cadences since the endpoint skips users who aren't due. README documents the install. Output logs to data/coaching-cron.log (gitignored). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -873,6 +873,19 @@ repo. For this HTTPS deployment the env must set:
|
|||||||
After changing `.env`, apply with `docker compose up -d` (recreates the
|
After changing `.env`, apply with `docker compose up -d` (recreates the
|
||||||
container with the new env).
|
container with the new env).
|
||||||
|
|
||||||
|
**Weekly check-in cron.** `scripts/run-weekly-checkins.sh` reads the admin API
|
||||||
|
key from `.env` and POSTs `/discovery/coaching/run` (the Phase 3 batch). Install
|
||||||
|
it as a weekly cron on the host:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
( crontab -l 2>/dev/null | grep -v run-weekly-checkins.sh; \
|
||||||
|
echo '0 8 * * 1 /mnt/c/syncdata/impactflow-discovery/scripts/run-weekly-checkins.sh >/dev/null 2>&1' ) | crontab -
|
||||||
|
```
|
||||||
|
|
||||||
|
Running weekly services all cadences — the endpoint skips users who are not yet
|
||||||
|
due (biweekly/monthly), so a weekly tick is the finest needed. Output is
|
||||||
|
appended to `data/coaching-cron.log`. (On WSL, cron only runs while WSL is up.)
|
||||||
|
|
||||||
## Quick Start With Docker
|
## Quick Start With Docker
|
||||||
|
|
||||||
This path requires Docker Desktop or another Docker Engine installation with
|
This path requires Docker Desktop or another Docker Engine installation with
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Weekly coaching check-in batch (Phase 3). Reads the admin API key from .env
|
||||||
|
# and POSTs the batch endpoint, which generates a check-in for every eligible
|
||||||
|
# user whose cadence is due. Invoked by a weekly cron entry.
|
||||||
|
#
|
||||||
|
# Override the target with IMPACTFLOW_BASE_URL (defaults to the local container).
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
BASE="${IMPACTFLOW_BASE_URL:-http://localhost:8011}"
|
||||||
|
LOG="$DIR/data/coaching-cron.log"
|
||||||
|
|
||||||
|
KEY="$(grep '^IMPACTFLOW_API_KEY=' "$DIR/.env" | cut -d= -f2 | tr -d '\r\n')"
|
||||||
|
if [[ -z "$KEY" ]]; then
|
||||||
|
echo "$(date -u +%FT%TZ) ERROR: IMPACTFLOW_API_KEY not found in $DIR/.env" >> "$LOG"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
resp="$(curl -sS -m 120 -X POST -H "X-API-Key: $KEY" \
|
||||||
|
"$BASE/discovery/coaching/run" 2>&1 || echo '{"error":"curl failed"}')"
|
||||||
|
echo "$(date -u +%FT%TZ) $resp" >> "$LOG"
|
||||||
Reference in New Issue
Block a user