Phase 9a: Schulkalender — Bundesland-Auswahl + Monatsansicht mit Ferien
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
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>
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
package database
|
||||
|
||||
// CalendarMigrations creates the three calendar tables for Phase 9a:
|
||||
//
|
||||
// cal_public_event — read-only snapshot of school holidays + public
|
||||
// holidays from OpenHolidaysAPI. Imported on first
|
||||
// boot via seed/calendar_holidays.json.
|
||||
// cal_school_config — per-Rektor bundesland selection (1 row per user).
|
||||
// cal_school_event — user-managed school events (Fortbildung,
|
||||
// Schulfeier, Klassenfahrt etc.).
|
||||
//
|
||||
// cal_public_event is global (no created_by_user_id) because the data is the
|
||||
// same for every school in a given bundesland. School-events are
|
||||
// per-tenant.
|
||||
func CalendarMigrations() []string {
|
||||
return []string{
|
||||
`CREATE TABLE IF NOT EXISTS cal_public_event (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
region VARCHAR(8) NOT NULL,
|
||||
event_type VARCHAR(20) NOT NULL CHECK (event_type IN ('public_holiday', 'school_holiday')),
|
||||
name_de VARCHAR(255) NOT NULL,
|
||||
name_en VARCHAR(255),
|
||||
start_date DATE NOT NULL,
|
||||
end_date DATE NOT NULL,
|
||||
source VARCHAR(50) DEFAULT 'OpenHolidaysAPI',
|
||||
created_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
UNIQUE(region, event_type, name_de, start_date),
|
||||
CHECK (end_date >= start_date)
|
||||
)`,
|
||||
|
||||
`CREATE TABLE IF NOT EXISTS cal_school_config (
|
||||
user_id UUID PRIMARY KEY,
|
||||
bundesland VARCHAR(8) NOT NULL,
|
||||
school_year_start DATE,
|
||||
school_year_end DATE,
|
||||
created_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ DEFAULT NOW()
|
||||
)`,
|
||||
|
||||
`CREATE TABLE IF NOT EXISTS cal_school_event (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
created_by_user_id UUID NOT NULL,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
description TEXT,
|
||||
event_type VARCHAR(30) NOT NULL
|
||||
CHECK (event_type IN ('fortbildung','schulfeier','klassenfahrt','projekttag','eltern_info','andere')),
|
||||
is_school_free BOOLEAN DEFAULT false,
|
||||
start_date DATE NOT NULL,
|
||||
end_date DATE NOT NULL,
|
||||
start_time TIME,
|
||||
end_time TIME,
|
||||
affected_class_ids UUID[] DEFAULT '{}',
|
||||
visible_to_parents BOOLEAN DEFAULT true,
|
||||
notify_parents BOOLEAN DEFAULT false,
|
||||
notify_students BOOLEAN DEFAULT false,
|
||||
notification_lead_days INT[] DEFAULT '{7,1}',
|
||||
created_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
CHECK (end_date >= start_date)
|
||||
)`,
|
||||
|
||||
// Indexes — public events are queried by region + date range. School
|
||||
// events are queried by owner + date range.
|
||||
`CREATE INDEX IF NOT EXISTS idx_cal_public_event_region_date
|
||||
ON cal_public_event(region, start_date, end_date)`,
|
||||
`CREATE INDEX IF NOT EXISTS idx_cal_school_event_user_date
|
||||
ON cal_school_event(created_by_user_id, start_date, end_date)`,
|
||||
}
|
||||
}
|
||||
@@ -221,6 +221,9 @@ func Migrate(db *DB) error {
|
||||
// Append timetable solution migrations (see timetable_solution_migrations.go)
|
||||
migrations = append(migrations, TimetableSolutionMigrations()...)
|
||||
|
||||
// Append calendar migrations (see calendar_migrations.go).
|
||||
migrations = append(migrations, CalendarMigrations()...)
|
||||
|
||||
for _, migration := range migrations {
|
||||
_, err := db.Pool.Exec(ctx, migration)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user