#!/usr/bin/env bash # build-oracle-ef.sh — generate the EF (1962) regression oracle by fetching # missalemeum's per-date proper API (the same source lectio's trad scraper uses, # built on Divinum Officium data) for 2025-2026. # # NOT run by `go test`. Requires network + curl + jq + GNU date. From repo root: # scripts/build-oracle-ef.sh # Writes internal/calendar/testdata/oracle-ef.json: # { "YYYY-MM-DD": {"tempora": "...", "title": "...", "rank": N, "colour": "w"} } # tempora is "" when missalemeum returns null (then the temporal identity is in # title); the Go test derives the season from tempora-or-title. set -euo pipefail out=internal/calendar/testdata/oracle-ef.json mkdir -p "$(dirname "$out")" work=$(mktemp -d) for y in 2025 2026; do d="$y-01-01" while [ "$(date -d "$d" +%Y)" = "$y" ]; do echo "$d" d=$(date -d "$d +1 day" +%F) done done > "$work/dates" fetch() { local d="$1" local j j=$(curl -sf "https://www.missalemeum.com/en/api/v5/proper/$d" || true) printf '%s' "$j" | jq -c --arg d "$d" \ '{($d): (.[0].info | {tempora:(.tempora // ""), title:.title, rank:.rank, colour:(.colors|join(""))})}' \ 2>/dev/null || true } export -f fetch xargs -P 12 -I{} bash -c 'fetch "$@"' _ {} < "$work/dates" | jq -s 'add' > "$out" echo "wrote $out ($(jq 'length' "$out") days)" >&2 rm -rf "$work"