mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-19 01:17:06 +03:00
refine sort func
This commit is contained in:
parent
e30916f4c8
commit
9eb707bca3
@ -40,16 +40,28 @@ export default function LPRDebug() {
|
|||||||
|
|
||||||
const attempts = Object.keys(lprData).filter((attempt) => attempt != "train");
|
const attempts = Object.keys(lprData).filter((attempt) => attempt != "train");
|
||||||
|
|
||||||
|
// Get all events first to access their scores
|
||||||
|
const eventScores = new Map<string, number>();
|
||||||
|
attempts.forEach((attempt) => {
|
||||||
|
const parts = attempt.split("-");
|
||||||
|
const eventId = `${parts[0]}-${parts[1]}`;
|
||||||
|
const event = lprData[eventId];
|
||||||
|
if (event?.data?.sub_label_score) {
|
||||||
|
eventScores.set(attempt, event.data.sub_label_score);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return attempts.sort((a, b) => {
|
return attempts.sort((a, b) => {
|
||||||
const [, , plateA, scoreA] = a.split("-");
|
const scoreA = eventScores.get(a) || 0;
|
||||||
const [, , plateB, scoreB] = b.split("-");
|
const scoreB = eventScores.get(b) || 0;
|
||||||
|
|
||||||
switch (sortBy) {
|
switch (sortBy) {
|
||||||
case "score_desc":
|
case "score_desc":
|
||||||
return (Number(scoreB) || 0) - (Number(scoreA) || 0);
|
return scoreB - scoreA;
|
||||||
case "score_asc":
|
case "score_asc":
|
||||||
return (Number(scoreA) || 0) - (Number(scoreB) || 0);
|
return scoreA - scoreB;
|
||||||
case "time_desc":
|
case "time_desc":
|
||||||
|
// For time sorting, we'll use the file creation order (default order)
|
||||||
return b.localeCompare(a);
|
return b.localeCompare(a);
|
||||||
case "time_asc":
|
case "time_asc":
|
||||||
return a.localeCompare(b);
|
return a.localeCompare(b);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user