97e37837ee
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-school (push) Successful in 29s
CI / test-go-edu-search (push) Successful in 27s
CI / test-python-klausur (push) Failing after 2m50s
CI / test-python-agent-core (push) Successful in 18s
CI / test-nodejs-website (push) Successful in 21s
Backend (school-service):
- cal_public_event (region, event_type, name_de, name_en, start/end,
UNIQUE(region, event_type, name_de, start_date)) — global snapshot.
- cal_school_config (user_id PRIMARY KEY, bundesland, school year dates).
- cal_school_event — Schul-eigene Termine; CRUD folgt in 9b.
- GET /calendar/holidays?region=&from=&to= — Range-Query against
cal_public_event, ordered by start_date.
- GET / PUT /calendar/config — upsert Bundesland per User.
- SeedFromSnapshot reads internal/seed/calendar_holidays.json on every
boot; idempotent via the unique constraint. Async goroutine so the
HTTP server starts immediately even if the seed file is large.
Data source:
- scripts/calendar-snapshot.sh ruft openholidaysapi.org fuer alle 16
Bundeslaender x 3 Schuljahre und schreibt
school-service/internal/seed/calendar_holidays.json (854 Events,
Stand Schuljahre 2026-2028).
- Dockerfile kopiert das seed/-Verzeichnis ins Image, damit die
Container-Datenbank beim ersten Start gefuellt wird.
Frontend (studio-v2):
- /schulkalender Page mit Gradient + Blobs wie /stundenplan und
/korrektur — gleicher Visual-Style.
- BundeslandWizard: zeigt alle 16 Laender als Dropdown, speichert
bei Klick die Config und switcht zur Monatsansicht.
- MonthView: 6-Wochen-Grid Mo-So, Feiertage rose-toned, Schulferien
amber-toned, heutiges Datum mit Indigo-Ring. Prev/Next/Heute
Navigation.
- lib/schulkalender/api.ts re-uses the stundenplan JWT helper so
auth-mode wechselt nicht.
- Sidebar bekommt einen Schulkalender-Eintrag (Icon mit Datum-Dots,
Pfad /schulkalender) in allen 26 Sprachen.
Tests:
- Go: 3 neue Validator-Tests (Bundesland len=5, EventType oneof,
Pflichtfelder). 77 Tests gesamt, alle gruen.
- Playwright: e2e/schulkalender.spec.ts mit Wizard, Save-Flow,
MonthView-Render, Heute-Button, Sidebar-Link. Hermetisch via
mockCalendarApi.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
87 lines
3.0 KiB
Bash
Executable File
87 lines
3.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Snapshot Public Holidays + School Holidays for all 16 German Bundeslaender
|
|
# from openholidaysapi.org. The result is committed to the repo and imported
|
|
# at first DB boot by school-service. Re-run yearly (or whenever the next
|
|
# school year's data needs to be added).
|
|
#
|
|
# Usage: bash scripts/calendar-snapshot.sh [FIRST_YEAR] [LAST_YEAR]
|
|
# defaults: current year .. current year + 2
|
|
#
|
|
# Output: school-service/internal/seed/calendar_holidays.json
|
|
# shape: [{ region, event_type, name_de, name_en, start_date, end_date }, ...]
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
OUT="$ROOT/school-service/internal/seed/calendar_holidays.json"
|
|
mkdir -p "$(dirname "$OUT")"
|
|
|
|
START_YEAR="${1:-$(date +%Y)}"
|
|
END_YEAR="${2:-$((START_YEAR + 2))}"
|
|
API="https://openholidaysapi.org"
|
|
|
|
# DE-XX codes for all 16 Bundeslaender (alphabetical).
|
|
REGIONS=(
|
|
"DE-BW" "DE-BY" "DE-BE" "DE-BB" "DE-HB" "DE-HH" "DE-HE" "DE-MV"
|
|
"DE-NI" "DE-NW" "DE-RP" "DE-SL" "DE-SN" "DE-ST" "DE-SH" "DE-TH"
|
|
)
|
|
|
|
if ! command -v jq >/dev/null 2>&1; then
|
|
echo "jq is required (brew install jq)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
TMP=$(mktemp)
|
|
trap 'rm -f "$TMP"' EXIT
|
|
echo '[]' > "$TMP"
|
|
|
|
fetch() {
|
|
local endpoint="$1" region="$2" year="$3"
|
|
curl -sf -G "$API/$endpoint" \
|
|
--data-urlencode "countryIsoCode=DE" \
|
|
--data-urlencode "languageIsoCode=DE" \
|
|
--data-urlencode "validFrom=${year}-01-01" \
|
|
--data-urlencode "validTo=${year}-12-31" \
|
|
--data-urlencode "subdivisionCode=$region" \
|
|
|| echo '[]'
|
|
}
|
|
|
|
# Map OpenHolidaysAPI shape → our DB schema. The API returns an array of:
|
|
# { id, startDate, endDate, type, name: [{ language, text }], ... }
|
|
# We keep DE name as canonical, EN name if present, plus dates and a typed
|
|
# event_type discriminator. PublicHolidays and SchoolHolidays come from two
|
|
# separate endpoints.
|
|
normalise_jq='
|
|
map({
|
|
region: $region,
|
|
event_type: $event_type,
|
|
name_de: ((.name // []) | map(select(.language == "DE")) | .[0].text // ""),
|
|
name_en: ((.name // []) | map(select(.language == "EN")) | .[0].text // null),
|
|
start_date: .startDate,
|
|
end_date: .endDate
|
|
}) | map(select(.name_de != ""))
|
|
'
|
|
|
|
for region in "${REGIONS[@]}"; do
|
|
for year in $(seq "$START_YEAR" "$END_YEAR"); do
|
|
echo " $region $year — public" >&2
|
|
fetch "PublicHolidays" "$region" "$year" \
|
|
| jq --arg region "$region" --arg event_type "public_holiday" "$normalise_jq" \
|
|
| jq -s --slurpfile existing "$TMP" '$existing[0] + .[0]' > "$TMP.new"
|
|
mv "$TMP.new" "$TMP"
|
|
|
|
echo " $region $year — school" >&2
|
|
fetch "SchoolHolidays" "$region" "$year" \
|
|
| jq --arg region "$region" --arg event_type "school_holiday" "$normalise_jq" \
|
|
| jq -s --slurpfile existing "$TMP" '$existing[0] + .[0]' > "$TMP.new"
|
|
mv "$TMP.new" "$TMP"
|
|
done
|
|
done
|
|
|
|
# Deduplicate (the API sometimes returns overlapping rows for events that
|
|
# straddle a year boundary) and sort for a stable diff.
|
|
jq 'unique_by({region, event_type, name_de, start_date}) | sort_by([.region, .start_date])' \
|
|
"$TMP" > "$OUT"
|
|
|
|
echo
|
|
echo "Wrote $(jq length "$OUT") events to $OUT"
|