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() const parts = image.split("-");
.reverse() return {
.forEach((image) => { filename: image,
const parts = image.split("-"); timestamp: Number.parseFloat(parts[0]),
const data = { eventId: `${parts[0]}-${parts[1]}`,
filename: image, name: parts[2],
timestamp: Number.parseFloat(parts[0]), score: Number.parseFloat(parts[3]),
eventId: `${parts[0]}-${parts[1]}`, };
name: parts[2], });
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];
} }
}); });