Fas 1b punkt 6: First Scan Coach + aktiveringsmätning
This commit is contained in:
@@ -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 };
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user