Phase 6b/7b: per-child decoded periods, separate brief blocks, idempotent calendar (AUD-119)
- Parse each child's own "Today" day widget for the timetable (FR-16); drop the school-wide week calendar's lesson grid and clean the leaked routine rows. - Add the editable codes map (FR-17): subjects, rooms, teachers and period labels, seeded, an unknown code falls back to the raw code; `school codes` CLI. - Brief: Finn's block first, then Harry's, four sections always present (FR-9); periods decoded into plain English; the undated tail is one counted line (FR-18). - Calendar: write periods + work due + work overdue + major events, per child, on every pass. Identity is the stable per-item key, so a re-run never re-inserts (FR-8). morning-brief.sh now runs scan -> calendar push -> notify. - Day-widget labels are 12-hour: 1-6 read as PM, fixing afternoon periods. Proven live on .13: image 0.6.2-phase6b7b; both children's briefs decoded and separate; 35 events in calendar.school; runs 2 and 3 of the scan added nothing. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
# scripts/calendar-push.sh events [--days 14]
|
||||
#
|
||||
# Environment overrides:
|
||||
# IMAGE image tag (default 0.5.0-phase7)
|
||||
# IMAGE image tag (default 0.6.2-phase6b7b)
|
||||
# VOLUME SQLite volume (default compass-teams-nhs_compass-teams-nhs-data)
|
||||
# ENV_FILE HA config source (default environment.d/school-service.env)
|
||||
# SCHOOL_TIMEZONE family timezone (default Australia/Sydney)
|
||||
@@ -25,7 +25,7 @@ set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
|
||||
IMAGE="${IMAGE:-compass-teams-nhs/school:0.5.0-phase7}"
|
||||
IMAGE="${IMAGE:-compass-teams-nhs/school:0.6.2-phase6b7b}"
|
||||
VOLUME="${VOLUME:-compass-teams-nhs_compass-teams-nhs-data}"
|
||||
ENV_FILE="${ENV_FILE:-$REPO_ROOT/environment.d/school-service.env}"
|
||||
SCHOOL_TIMEZONE="${SCHOOL_TIMEZONE:-Australia/Sydney}"
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
#
|
||||
# This is the bounded command the 6:00am n8n schedule runs:
|
||||
# 1. scan Compass for both children (read-only; skipped with --no-scan),
|
||||
# 2. build one brief per boy and one combined brief to Jo and Sam,
|
||||
# 3. deliver them through the house Apprise API on `.35:8210`,
|
||||
# 4. record every delivery in `notifications` and every exit code loudly.
|
||||
# 2. write the day's periods, due work, overdue work and school events to
|
||||
# Sam's Home Assistant School calendar (idempotent; skipped with --no-calendar),
|
||||
# 3. build one brief per boy and one combined brief to Jo and Sam,
|
||||
# 4. deliver them through the house Apprise API on `.35:8210`,
|
||||
# 5. record every delivery in `notifications` and every exit code loudly.
|
||||
#
|
||||
# A failed scan is never reported as "nothing due" (FR-12): the brief opens with
|
||||
# the failure, and this script exits non-zero so the n8n execution is visibly
|
||||
@@ -16,13 +18,14 @@
|
||||
# is only exported into the container environment.
|
||||
#
|
||||
# Usage:
|
||||
# scripts/morning-brief.sh # scan, then send
|
||||
# scripts/morning-brief.sh --no-scan # send from the latest scan
|
||||
# scripts/morning-brief.sh # scan, calendar, then send
|
||||
# scripts/morning-brief.sh --no-scan # calendar and send from the latest scan
|
||||
# scripts/morning-brief.sh --no-scan --no-calendar # send only
|
||||
# scripts/morning-brief.sh --dry-run # build and print, send nothing
|
||||
# scripts/morning-brief.sh --channel email # limit the channels
|
||||
#
|
||||
# Environment overrides:
|
||||
# IMAGE image tag (default 0.6.1-phase8)
|
||||
# IMAGE image tag (default 0.6.2-phase6b7b)
|
||||
# VOLUME SQLite volume (default compass-teams-nhs_compass-teams-nhs-data)
|
||||
# ENV_FILE service env file (default environment.d/school-service.env)
|
||||
# SCHOOL_TIMEZONE family timezone (default Australia/Sydney)
|
||||
@@ -31,18 +34,20 @@ set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
|
||||
IMAGE="${IMAGE:-compass-teams-nhs/school:0.6.1-phase8}"
|
||||
IMAGE="${IMAGE:-compass-teams-nhs/school:0.6.2-phase6b7b}"
|
||||
VOLUME="${VOLUME:-compass-teams-nhs_compass-teams-nhs-data}"
|
||||
ENV_FILE="${ENV_FILE:-$REPO_ROOT/environment.d/school-service.env}"
|
||||
SCHOOL_TIMEZONE="${SCHOOL_TIMEZONE:-Australia/Sydney}"
|
||||
DOCKER_TIMEOUT="${DOCKER_TIMEOUT:-600}"
|
||||
|
||||
NO_SCAN=0
|
||||
NO_CALENDAR=0
|
||||
NOTIFY_ARGS=()
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--no-scan) NO_SCAN=1; shift ;;
|
||||
--dry-run) NOTIFY_ARGS+=(--dry-run); shift ;;
|
||||
--no-calendar) NO_CALENDAR=1; shift ;;
|
||||
--dry-run) NOTIFY_ARGS+=(--dry-run); NO_CALENDAR=1; shift ;;
|
||||
--channel) NOTIFY_ARGS+=(--channel "$2"); shift 2 ;;
|
||||
--only) NOTIFY_ARGS+=(--only "$2"); shift 2 ;;
|
||||
*) echo "unknown argument: $1" >&2; exit 2 ;;
|
||||
@@ -55,7 +60,8 @@ if [[ -f "$ENV_FILE" ]]; then
|
||||
while IFS= read -r line; do
|
||||
case "$line" in
|
||||
SCHOOL_APPRISE_URL=*|SCHOOL_APPRISE_KEY=*|SCHOOL_APPRISE_TOKEN=*|SCHOOL_APPRISE_TIMEOUT=*|\
|
||||
SCHOOL_APPRISE_CHANNELS=*|SCHOOL_APPRISE_TAGS=*|SCHOOL_APPRISE_PARENTS=*|SCHOOL_NOTIFY_TOKEN=*)
|
||||
SCHOOL_APPRISE_CHANNELS=*|SCHOOL_APPRISE_TAGS=*|SCHOOL_APPRISE_PARENTS=*|SCHOOL_NOTIFY_TOKEN=*|\
|
||||
SCHOOL_HA_URL=*|SCHOOL_HA_TOKEN=*|SCHOOL_HA_CALENDAR_ENTITY=*|SCHOOL_HA_INSECURE=*|SCHOOL_HA_TIMEOUT=*)
|
||||
key="${line%%=*}"
|
||||
val="${line#*=}"
|
||||
if [[ -z "${!key:-}" ]]; then
|
||||
@@ -83,6 +89,11 @@ run_school() {
|
||||
-e SCHOOL_APPRISE_CHANNELS="${SCHOOL_APPRISE_CHANNELS:-}" \
|
||||
-e SCHOOL_APPRISE_TAGS="${SCHOOL_APPRISE_TAGS:-}" \
|
||||
-e SCHOOL_APPRISE_PARENTS="${SCHOOL_APPRISE_PARENTS:-}" \
|
||||
-e SCHOOL_HA_URL="${SCHOOL_HA_URL:-}" \
|
||||
-e SCHOOL_HA_TOKEN="${SCHOOL_HA_TOKEN:-}" \
|
||||
-e SCHOOL_HA_CALENDAR_ENTITY="${SCHOOL_HA_CALENDAR_ENTITY:-}" \
|
||||
-e SCHOOL_HA_INSECURE="${SCHOOL_HA_INSECURE:-}" \
|
||||
-e SCHOOL_HA_TIMEOUT="${SCHOOL_HA_TIMEOUT:-}" \
|
||||
"$IMAGE" "$@"
|
||||
}
|
||||
|
||||
@@ -97,15 +108,31 @@ if [[ "$NO_SCAN" -eq 0 ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# 2. Build and send the briefs.
|
||||
# 2. Write the calendar for every child. The write is idempotent: the same
|
||||
# item is checked on every pass and never re-inserted (FR-8). A failure is
|
||||
# loud and makes the run exit non-zero.
|
||||
calendar_rc=0
|
||||
if [[ "$NO_CALENDAR" -eq 0 ]]; then
|
||||
echo "== write the School calendar (periods + due + overdue + events) =="
|
||||
if [[ -n "${SCHOOL_HA_URL:-}" && -n "${SCHOOL_HA_TOKEN:-}" ]]; then
|
||||
if ! run_school calendar push; then
|
||||
calendar_rc=$?
|
||||
echo "calendar push failed (exit $calendar_rc)" >&2
|
||||
fi
|
||||
else
|
||||
echo "SCHOOL_HA_URL/SCHOOL_HA_TOKEN are not set: the calendar was not written" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
# 3. Build and send the briefs.
|
||||
echo "== send the morning briefs =="
|
||||
notify_rc=0
|
||||
if ! run_school notify run "${NOTIFY_ARGS[@]+"${NOTIFY_ARGS[@]}"}"; then
|
||||
notify_rc=$?
|
||||
fi
|
||||
|
||||
if [[ "$scan_rc" -ne 0 || "$notify_rc" -ne 0 ]]; then
|
||||
echo "morning brief FAILED: scan_rc=$scan_rc notify_rc=$notify_rc" >&2
|
||||
if [[ "$scan_rc" -ne 0 || "$calendar_rc" -ne 0 || "$notify_rc" -ne 0 ]]; then
|
||||
echo "morning brief FAILED: scan_rc=$scan_rc calendar_rc=$calendar_rc notify_rc=$notify_rc" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "morning brief complete: both boys + the combined brief to Jo and Sam"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
# scripts/parse-compass.sh [--child Harry] [--run latest] [--classify auto]
|
||||
#
|
||||
# Environment overrides:
|
||||
# IMAGE image tag (default 0.5.0-phase7)
|
||||
# IMAGE image tag (default 0.6.2-phase6b7b)
|
||||
# VOLUME SQLite volume (default compass-teams-nhs_compass-teams-nhs-data)
|
||||
# RAW_ROOT host path to var/raw (default <repo>/var/raw)
|
||||
# SCHOOL_TIMEZONE family timezone (default Australia/Melbourne)
|
||||
@@ -22,7 +22,7 @@ set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
|
||||
IMAGE="${IMAGE:-compass-teams-nhs/school:0.5.0-phase7}"
|
||||
IMAGE="${IMAGE:-compass-teams-nhs/school:0.6.2-phase6b7b}"
|
||||
VOLUME="${VOLUME:-compass-teams-nhs_compass-teams-nhs-data}"
|
||||
RAW_ROOT="${RAW_ROOT:-$REPO_ROOT/var/raw}"
|
||||
SCHOOL_TIMEZONE="${SCHOOL_TIMEZONE:-Australia/Melbourne}"
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
# scripts/scan-compass.sh --child Harry --child Finn --classify none
|
||||
#
|
||||
# Environment overrides:
|
||||
# IMAGE image tag (default compass-teams-nhs/school:0.5.0-phase7)
|
||||
# IMAGE image tag (default compass-teams-nhs/school:0.6.2-phase6b7b)
|
||||
# VOLUME SQLite volume (default compass-teams-nhs_compass-teams-nhs-data)
|
||||
# RAW_ROOT host path to var/raw (default <repo>/var/raw)
|
||||
# SCHOOL_TIMEZONE family timezone (default Australia/Melbourne)
|
||||
@@ -33,7 +33,7 @@ set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
|
||||
IMAGE="${IMAGE:-compass-teams-nhs/school:0.5.0-phase7}"
|
||||
IMAGE="${IMAGE:-compass-teams-nhs/school:0.6.2-phase6b7b}"
|
||||
VOLUME="${VOLUME:-compass-teams-nhs_compass-teams-nhs-data}"
|
||||
RAW_ROOT="${RAW_ROOT:-$REPO_ROOT/var/raw}"
|
||||
SCHOOL_TIMEZONE="${SCHOOL_TIMEZONE:-Australia/Melbourne}"
|
||||
|
||||
Reference in New Issue
Block a user