S5: onboarding → minne + smaksignaler (user_stated)

This commit is contained in:
Sven (AAMOS AI)
2026-08-11 04:43:43 +07:00
parent 1e18146665
commit f86a37dd33
26 changed files with 10812 additions and 2 deletions
+4
View File
@@ -12,6 +12,7 @@ import { computeDailyTargets, DEFAULT_TARGETS } from "@app/nutrition-engine";
import { errors, parse } from "../lib/errors.js";
import { audit, generateInviteCode, getActiveHouseholdId } from "../lib/helpers.js";
import { loadEntitlementsWithToken } from "../lib/entitlements.js";
import { syncOnboardingMemory } from "../lib/onboardingMemory.js";
/** Profil, preferenser, samtycken, dagsmål, GDPR-export/-radering (spec §6, §56). */
export async function meRoutes(app: FastifyInstance) {
@@ -120,6 +121,9 @@ export async function meRoutes(app: FastifyInstance) {
target: schema.userPreferences.userId,
set: { ...input.preferences, updatedAt: new Date() },
});
// S5: spegla uttryckligen angivna preferenser i minne + smaksignaler.
await syncOnboardingMemory(app.db, req.userId, input.preferences);
}
let householdId: string | null = await getActiveHouseholdId(app.db, req.userId);
+11
View File
@@ -12,6 +12,7 @@ import {
import { t } from "../lib/i18n.js";
import { KNOWN_FLAGS } from "@app/feature-flags";
import { syncOnboardingMemory } from "../lib/onboardingMemory.js";
/**
* Progressive onboarding (FAS 1b): 3-layer flow.
@@ -227,6 +228,16 @@ export async function onboardingRoutes(app: FastifyInstance) {
});
}
// S5: spegla alla uttryckligen angivna preferenser i minne + smaksignaler.
const [completedPrefs] = await app.db
.select()
.from(schema.userPreferences)
.where(eq(schema.userPreferences.userId, req.userId))
.limit(1);
if (completedPrefs) {
await syncOnboardingMemory(app.db, req.userId, completedPrefs);
}
const [user] = await app.db
.update(schema.users)
.set({
+2
View File
@@ -276,6 +276,7 @@ export async function recommendationRoutes(app: FastifyInstance) {
id: schema.tasteSignals.id,
userId: schema.tasteSignals.userId,
axis: schema.tasteSignals.axis,
target: schema.tasteSignals.target,
direction: schema.tasteSignals.direction,
strength: schema.tasteSignals.strength,
origin: schema.tasteSignals.origin,
@@ -286,6 +287,7 @@ export async function recommendationRoutes(app: FastifyInstance) {
.where(eq(schema.tasteSignals.userId, req.userId));
tasteSignals = tasteRows.map((t) => ({
...t,
target: t.target ?? undefined,
refRecipeId: t.refRecipeId ?? undefined,
createdAt: t.createdAt.toISOString(),
}));