perf(faith): warm liturgical cache + fix 1962 rendering
CI / update (push) Successful in 3m59s

Pre-compute romcal year maps on server boot for current + next civil year
across en/de/la in each rite's default diocese, non-blocking so startup is
unaffected.

Also fixes several 1962-rite rendering bugs: commemorations previously
leaked 1969-shape ids (e.g. andrew_apostle) next to proper 1962 sancti;
station church names came through unresolved because RomcalConfig's
internal i18next has no bundle loaded; season names arrived as raw keys
(advent.season) for the same reason. All three now resolve locally via
the shipped 1962 bundle with Latin as fallback. ClassIV ferias get a
small dot on the grid.
This commit is contained in:
2026-04-21 08:04:16 +02:00
parent dd612f6535
commit 2b1a415ab6
9 changed files with 202 additions and 29 deletions
+11
View File
@@ -5,6 +5,7 @@ import * as auth from "./auth"
import { initializeScheduler } from "./lib/server/scheduler"
import { dbConnect } from "./utils/db"
import { errorWithVerse, getRandomVerse } from "$lib/server/errorQuote"
import { warmLiturgicalCache } from "$lib/server/liturgicalCalendar"
async function timing({ event, resolve }: Parameters<Handle>[0]) {
const marks: Record<string, number> = {};
@@ -43,6 +44,16 @@ await dbConnect().then(() => {
// Don't crash the server - API routes will attempt reconnection
});
// Warm liturgical calendar cache in the background — non-blocking so the
// server starts accepting requests immediately; any request arriving before
// warmup completes falls back to lazy computation (still correct, just cold).
{
const t0 = performance.now();
warmLiturgicalCache()
.then(() => console.log(`✅ Liturgical calendar cache warmed in ${Math.round(performance.now() - t0)}ms`))
.catch((error) => console.error('⚠️ Liturgical calendar warmup failed:', error));
}
async function authorization({ event, resolve }: Parameters<Handle>[0]) {
const session = await event.locals.timing.measure('auth', () => event.locals.auth());
event.locals.session = session;