diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-27 12:33:47 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-27 12:33:47 +0200 |
| commit | f5afb407beab795e371c36a3229e991e48c366fe (patch) | |
| tree | b9378cca00e46a1b063d53f3cfa52546ae782f9f /scripts | |
| parent | 56f3b8161f73c33fe6e25f6461d3f061af427e9e (diff) | |
| download | lectio-f5afb407beab795e371c36a3229e991e48c366fe.tar.gz lectio-f5afb407beab795e371c36a3229e991e48c366fe.zip | |
test(calendar): regression oracle vs calapi 2020-2040 (0 season mismatches)
Caught + fixed an Advent-start bug: anchor on Christmas Eve, not Dec 25, so
years where Dec 25 is a Sunday don't lose the first week of Advent. Rank-class
diffs (324) are informational — the initial sanctoral dataset is partial.
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/build-oracle.sh | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/build-oracle.sh b/scripts/build-oracle.sh new file mode 100755 index 0000000..2d5b329 --- /dev/null +++ b/scripts/build-oracle.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# build-oracle.sh — generate the regression oracle snapshot for the calendar +# engine by fetching the authoritative General Roman Calendar from calapi +# (calendarium-romanum) month by month, 2020-2040. +# +# NOT run by `go test`. Requires network + curl + jq. Run from the repo root: +# scripts/build-oracle.sh +# Writes internal/calendar/testdata/oracle-2020-2040.json as +# { "YYYY-MM-DD": {"season": "...", "rank_num": N.N}, ... } +# where season/rank_num are the top celebration's (celebrations[0]). +set -euo pipefail + +base="http://calapi.inadiutorium.cz/api/v0/en/calendars/general-en" +out="internal/calendar/testdata/oracle-2020-2040.json" +mkdir -p "$(dirname "$out")" +tmp="$(mktemp)" + +echo "{" > "$tmp" +first=1 +for y in $(seq 2020 2040); do + for m in $(seq 1 12); do + month_json="$(curl -sf "$base/$y/$m")" + # emit "date": {"season":..., "rank_num":...} for each day, comma-separated + rows="$(printf '%s' "$month_json" | jq -r '.[] | "\(.date)\t\(.season)\t\(.celebrations[0].rank_num)"')" + while IFS=$'\t' read -r date season rank; do + [ -n "$date" ] || continue + if [ "$first" -eq 1 ]; then first=0; else printf ",\n" >> "$tmp"; fi + printf ' "%s": {"season": "%s", "rank_num": %s}' "$date" "$season" "$rank" >> "$tmp" + done <<< "$rows" + done + echo " ...$y done" >&2 +done +printf "\n}\n" >> "$tmp" +mv "$tmp" "$out" +echo "wrote $out" >&2 |
