From f5afb407beab795e371c36a3229e991e48c366fe Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 27 Jul 2026 12:33:47 +0200 Subject: test(calendar): regression oracle vs calapi 2020-2040 (0 season mismatches) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- scripts/build-oracle.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 scripts/build-oracle.sh (limited to 'scripts/build-oracle.sh') 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 -- cgit v1.3