feat(vision): surface the recognized plate in the booth UI
The ANPR plate was saved (device_events kind:"read") but had no UI. Extend GET /api/snapshots/by-identity/:identity to also return plates[] (plate, confidence, region, direction, snapshotId, at) for that session, and render each as a cyan "Plate: AA558EE 100%" chip in the SnapshotStrip — so it shows in both the booth event-detail modal and the pay modal, beside the evidence photo, no separate screen. Deduped by plate+direction; session:read gated; i18n sq+en. Verified: by-identity returns plates[] for a seeded read (200, AA558EE 0.999 Albania entry). Build + lint green. Claude-Session: https://claude.ai/code/session_01Xcm6ikLgGoCxxHrxtjkk5V
This commit is contained in:
@@ -68,7 +68,44 @@ export async function snapshotRoutes(app: FastifyInstance, db: Db): Promise<void
|
||||
});
|
||||
}
|
||||
|
||||
return { snapshots: rows, failures };
|
||||
// Recognized PLATES for this session: kind="read" telemetry from the ANPR-on-
|
||||
// snapshot path (snapshot.ts → recognizePlate). Advisory — a record of the plate
|
||||
// observed for the session, shown beside the image. Newest first.
|
||||
const plateRows = db
|
||||
.select({ detail: deviceEvents.detail, occurredAt: deviceEvents.occurredAt })
|
||||
.from(deviceEvents)
|
||||
.where(and(eq(deviceEvents.category, "camera"), eq(deviceEvents.kind, "read")))
|
||||
.orderBy(desc(deviceEvents.occurredAt))
|
||||
.all();
|
||||
const plates: {
|
||||
plate: string;
|
||||
confidence: number | null;
|
||||
region: string | null;
|
||||
direction: "entry" | "exit" | null;
|
||||
snapshotId: string | null;
|
||||
at: string;
|
||||
}[] = [];
|
||||
for (const row of plateRows) {
|
||||
const d = (row.detail ?? {}) as {
|
||||
identity?: string;
|
||||
plate?: string;
|
||||
confidence?: number;
|
||||
region?: string | null;
|
||||
direction?: string;
|
||||
snapshotId?: string;
|
||||
};
|
||||
if (d.identity !== identity || !d.plate) continue;
|
||||
plates.push({
|
||||
plate: d.plate,
|
||||
confidence: typeof d.confidence === "number" ? d.confidence : null,
|
||||
region: d.region ?? null,
|
||||
direction: d.direction === "entry" || d.direction === "exit" ? d.direction : null,
|
||||
snapshotId: d.snapshotId ?? null,
|
||||
at: row.occurredAt ?? "",
|
||||
});
|
||||
}
|
||||
|
||||
return { snapshots: rows, failures, plates };
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user