Clean up decision logic

This commit is contained in:
Nicolas Mowen 2025-10-21 16:03:08 -06:00
parent 6d662151de
commit 7c0a97520a

View File

@ -197,18 +197,24 @@ export function GroupedClassificationCard({
let best: undefined | ClassificationItemData = undefined;
group.forEach((item) => {
if (best?.score == undefined || (item.score && best.score < item.score)) {
best = item;
if (item?.name != undefined && item.name != "none") {
if (
best?.score == undefined ||
(item.score && best.score < item.score)
) {
best = item;
}
}
});
if (!best) {
return undefined;
return group[0];
}
const bestTyped: ClassificationItemData = best;
return {
...bestTyped,
name: event?.sub_label || bestTyped.name,
score: event?.data?.sub_label_score || bestTyped.score,
};
}, [group, event]);