fix(3b): delad kompletteringsväg för legacy /cook + deterministiska cooking-assumptions
- cookRecipeInputSchema utökas med actualPortionsEaten, leftoverEstimatePortions, leftoverNote - completeCookingSession-wrapper i apps/api/src/lib/cooking.ts hanterar summavalidering, persistens av svar, profiluppdateringar och analytics (started+completed) för båda vägarna - Legacy POST /v1/recipes/:id/cook använder wrappern med emitStartedEvent - GET /v1/recipes/:id/cooking-assumptions väljer deterministiskt bland icke-valfria ingredienser - i18n: nyckel cooked.portionsSumExceedsPlanned i samtliga 12 lokaler + server-i18n - Nya tester för legacy /cook och cooking-assumptions med valfri första ingrediens Refs: steg 3b-fix, granskningsrunda 2026-08-07
This commit is contained in:
@@ -32,7 +32,7 @@ import {
|
||||
todayIso,
|
||||
} from "../lib/helpers.js";
|
||||
import { requireFeature } from "../lib/entitlements.js";
|
||||
import { completeCookingSessionCore } from "../lib/cooking.js";
|
||||
import { completeCookingSession } from "../lib/cooking.js";
|
||||
|
||||
/** Recept: sök, detalj, betyg, favoriter, "jag har lagat", substitutioner, användarrecept. */
|
||||
export async function recipeRoutes(app: FastifyInstance) {
|
||||
@@ -433,7 +433,9 @@ export async function recipeRoutes(app: FastifyInstance) {
|
||||
})
|
||||
.returning();
|
||||
|
||||
const result = await completeCookingSessionCore(app, session!, req.userId, input, req.correlationId);
|
||||
const result = await completeCookingSession(app, session!, req.userId, input, req.correlationId, {
|
||||
emitStartedEvent: true,
|
||||
});
|
||||
|
||||
return { sessionId: session!.id, ...result };
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user