Fas 1b punkt 6: First Scan Coach + aktiveringsmätning

This commit is contained in:
Sven (AAMOS AI)
2026-08-06 04:14:49 +07:00
parent 2f3cdf8016
commit bd8df59138
29 changed files with 9378 additions and 29 deletions
+7 -1
View File
@@ -1,6 +1,6 @@
import type { FastifyInstance } from "fastify";
import { and, eq, gt, isNull } from "drizzle-orm";
import { schema } from "@app/database";
import { markMilestone, schema } from "@app/database";
import type { JobType, ScanType } from "@app/shared-types";
import { confirmScanInputSchema, createScanInputSchema, idParamSchema } from "@app/validation";
import { errors, parse } from "../lib/errors.js";
@@ -200,6 +200,12 @@ export async function scanRoutes(app: FastifyInstance) {
.set({ status: "completed", updatedAt: new Date() })
.where(eq(schema.scanJobs.id, id));
const acceptedCount = input.items.filter((i) => i.action !== "reject").length;
await markMilestone(app.db, householdId, "firstScanCompletedAt");
if (acceptedCount >= 5) {
await markMilestone(app.db, householdId, "fifthItemConfirmedAt");
}
return { ok: true, createdItemIds: created };
});