fix(reco): marknadsstyrda högtider + visningsnamn med å/ä/ö istället för slugs (MIKRO 61)
CI / Typecheck, test & build (push) Failing after 42s

This commit is contained in:
Sven (AAMOS AI)
2026-08-14 20:46:22 +07:00
parent 33c72ddacd
commit e6216bf735
+11 -6
View File
@@ -25,6 +25,7 @@ import {
import { DEFAULT_TARGETS, computeDailyTargets, summarizeDay } from "@app/nutrition-engine"; import { DEFAULT_TARGETS, computeDailyTargets, summarizeDay } from "@app/nutrition-engine";
import { parse } from "../lib/errors.js"; import { parse } from "../lib/errors.js";
import { getActiveHouseholdId, todayIso } from "../lib/helpers.js"; import { getActiveHouseholdId, todayIso } from "../lib/helpers.js";
import { loadLocalePreferences } from "../lib/localeContext.js";
/** /**
* "Vad ska vi äta?" (spec §18) appens viktigaste endpoint. * "Vad ska vi äta?" (spec §18) appens viktigaste endpoint.
@@ -189,14 +190,18 @@ export async function recommendationRoutes(app: FastifyInstance) {
targets, targets,
); );
// --- 5. Säsong & högtid (spec §28) --- // --- 5. Säsong & högtid (spec §28) marknadsstyrt via användarens region ---
const localePrefs = await loadLocalePreferences(app.db, req.userId);
const market = localePrefs.regionCode;
const events = await app.db const events = await app.db
.select() .select()
.from(schema.seasonEvents) .from(schema.seasonEvents)
.where(and(eq(schema.seasonEvents.active, true), eq(schema.seasonEvents.market, "SE"))); .where(and(eq(schema.seasonEvents.active, true), eq(schema.seasonEvents.market, market)));
const activeHolidayTags = events const activeEvents = events.filter((e) =>
.filter((e) => isEventActive({ dateRule: e.dateRule, leadDays: e.leadDays }, today)) isEventActive({ dateRule: e.dateRule, leadDays: e.leadDays }, today),
.map((e) => e.slug); );
const activeHolidayTags = activeEvents.map((e) => e.slug); // slugs → matchar recept-holidayTags (scoring)
const activeHolidayNames = activeEvents.map((e) => e.nameSv); // visningsnamn med å/ä/ö
// --- 6. Senast lagat (variation) + hushållsbetyg --- // --- 6. Senast lagat (variation) + hushållsbetyg ---
const cooks = householdId const cooks = householdId
@@ -468,7 +473,7 @@ export async function recommendationRoutes(app: FastifyInstance) {
context: { context: {
persons: ctx.persons, persons: ctx.persons,
season: ctx.currentSeason, season: ctx.currentSeason,
activeHolidays: activeHolidayTags, activeHolidays: activeHolidayNames,
remainingKcal: ctx.remainingKcal, remainingKcal: ctx.remainingKcal,
remainingProteinG: ctx.remainingProteinG, remainingProteinG: ctx.remainingProteinG,
craving: craving ?? null, craving: craving ?? null,