fix locale cache

This commit is contained in:
2026-07-08 22:49:24 -05:00
parent 5138e61854
commit 63d4ed9470
2 changed files with 6 additions and 6 deletions

View File

@@ -36,7 +36,7 @@ export async function GET(request: NextRequest) {
let fifaData: Awaited<ReturnType<typeof fetchFifaScores>>; let fifaData: Awaited<ReturnType<typeof fetchFifaScores>>;
try { try {
fifaData = await fetchFifaScores(locale); fifaData = await fetchFifaScores();
} catch { } catch {
return NextResponse.json({ return NextResponse.json({
updatedAt: new Date().toISOString(), updatedAt: new Date().toISOString(),

View File

@@ -575,13 +575,13 @@ export async function fetchMatchesAndTeamsFifa(locale: string = "de"): Promise<{
} }
// Holt Live-Scores von der FIFA-API. Gibt Map MatchNumber → Scores + FIFA-ID→App-Code-Map zurück. // Holt Live-Scores von der FIFA-API. Gibt Map MatchNumber → Scores + FIFA-ID→App-Code-Map zurück.
export async function fetchFifaScores(locale: string = "de"): Promise<{ // Scores/Status/Penalties/Winner sind sprachunabhängig → locale-freier Cache-Key.
export async function fetchFifaScores(): Promise<{
scores: Map<number, FifaScores>; scores: Map<number, FifaScores>;
fifaIdToAppCode: Map<string, string>; fifaIdToAppCode: Map<string, string>;
}> { }> {
return cached(`fifa:scores:${locale}`, 45_000, async () => { return cached("fifa:scores", 45_000, async () => {
const lang = locale === "en" ? "en" : "de"; const url = `${FIFA_BASE}/calendar/matches?language=en&count=500&idSeason=${FIFA_SEASON}`;
const url = `${FIFA_BASE}/calendar/matches?language=${lang}&count=500&idSeason=${FIFA_SEASON}`;
const res = await fetch(url, { const res = await fetch(url, {
cache: "no-store", cache: "no-store",
headers: { "User-Agent": "wm2026-board/1.0" }, headers: { "User-Agent": "wm2026-board/1.0" },
@@ -773,7 +773,7 @@ export async function attachFifaLiveData(
// --- Step 1: Scores von FIFA holen --- // --- Step 1: Scores von FIFA holen ---
let fifaData: Awaited<ReturnType<typeof fetchFifaScores>>; let fifaData: Awaited<ReturnType<typeof fetchFifaScores>>;
try { try {
fifaData = await fetchFifaScores(locale); fifaData = await fetchFifaScores();
} catch (err) { } catch (err) {
console.warn("[fifa-fetch] Scores fehlgeschlagen:", err instanceof Error ? err.message : err); console.warn("[fifa-fetch] Scores fehlgeschlagen:", err instanceof Error ? err.message : err);
return matches; return matches;