fix(skann): finetune dubblett – ta aldrig bort automatiskt, jamfor ej inom samma foto

Johans test visade tva falska positiva: 3:e smetana pa annan hylla forsvann,
och 2 olika gradde i EN bild -> bara en rakna, andra bortrensad. Orsak: (1)
auto-avmarkering tog bort riktiga varor, (2) varor jamfordes mot varandra inom
samma foto. Fix: markera men ta ALDRIG bort automatiskt (rejected=false, du
valjer); jamfor bara inom samma skanning nar det finns FLERA foton (overlapp),
aldrig tva behallare i ett och samma foto. Verifierat mot alla tre fallen.
This commit is contained in:
Claude
2026-08-18 19:19:04 +00:00
parent 2aaa7f9b3f
commit 7c06516e1e
2 changed files with 9 additions and 4 deletions
+6 -2
View File
@@ -338,6 +338,10 @@ async function annotateScanDuplicates(
const source = scanSource(job.scanType);
const now = new Date().toISOString();
// Jämför bara mot TIDIGARE bilder i samma skanning när det finns FLERA foton
// (överlappande vinklar). I ett enda foto är två liknande behållare oftast
// två riktiga varor flagga dem aldrig mot varandra.
const multiImage = (job.s3Keys?.length ?? 0) > 1;
const seen: typeof existing = [];
const items = result.items.map((it, idx) => {
@@ -349,9 +353,9 @@ async function annotateScanDuplicates(
source,
createdAt: now,
};
const pool = [...existing, ...seen];
const pool = multiImage ? [...existing, ...seen] : existing;
const [top] = findDuplicateCandidates(input, pool);
seen.push({ id: String(it.tempId ?? idx), ...input });
if (multiImage) seen.push({ id: String(it.tempId ?? idx), ...input });
if (!top) return { ...it, possibleDuplicate: null };
const match = pool.find((p) => p.id === top.itemId);
return {
+3 -2
View File
@@ -106,8 +106,9 @@ export default function ScanReviewScreen() {
dateIsUseBy: false,
confidence: item.confidence,
duplicate: item.possibleDuplicate ?? null,
// Hög säkerhet på dubblett → avmarkerad som standard (syns tydligt + går att ångra).
rejected: (item.possibleDuplicate?.score ?? 0) >= 0.7,
// Markera möjlig dubblett men ta ALDRIG bort automatiskt två av samma
// vara, eller en till på en annan hylla, är ofta helt riktigt. Du väljer.
rejected: false,
})),
);
}