Sort by event id

This commit is contained in:
Nicolas Mowen 2025-03-31 13:34:37 -06:00
parent b6a51485de
commit c3adca6bfd

View File

@ -410,23 +410,25 @@ function TrainingGrid({
const faceGroups = useMemo(() => { const faceGroups = useMemo(() => {
const groups: { [eventId: string]: RecognizedFaceData[] } = {}; const groups: { [eventId: string]: RecognizedFaceData[] } = {};
Array.from(new Set(attemptImages)) const faces = attemptImages.map((image) => {
.sort()
.reverse()
.forEach((image) => {
const parts = image.split("-"); const parts = image.split("-");
const data = { return {
filename: image, filename: image,
timestamp: Number.parseFloat(parts[0]), timestamp: Number.parseFloat(parts[0]),
eventId: `${parts[0]}-${parts[1]}`, eventId: `${parts[0]}-${parts[1]}`,
name: parts[2], name: parts[2],
score: Number.parseFloat(parts[3]), score: Number.parseFloat(parts[3]),
}; };
});
if (groups[data.eventId]) { faces
groups[data.eventId].push(data); .sort((a, b) => a.eventId.localeCompare(b.eventId))
.reverse()
.forEach((face) => {
if (groups[face.eventId]) {
groups[face.eventId].push(face);
} else { } else {
groups[data.eventId] = [data]; groups[face.eventId] = [face];
} }
}); });