[web] Sort scoreboard

This commit is contained in:
orosmatthew 2023-05-09 16:59:43 -04:00
parent 149037cf7d
commit 83b5d75ed1

View File

@ -14,7 +14,8 @@ export const load = (async () => {
problems: contest.problems.map((problem) => {
return { id: problem.id, friendlyName: problem.friendlyName };
}),
teams: contest.teams.map((team) => {
teams: contest.teams
.map((team) => {
return {
name: team.name,
solves: team.submissions.filter((submission) => {
@ -60,7 +61,9 @@ export const load = (async () => {
);
})
? team.submissions.find((submission) => {
return submission.problemId === problem.id && submission.state === 'Correct';
return (
submission.problemId === problem.id && submission.state === 'Correct'
);
})
? 'correct'
: 'incorrect'
@ -83,6 +86,21 @@ export const load = (async () => {
})
};
})
.sort((a, b) => {
if (a.solves > b.solves) {
return -1;
} else if (a.solves < b.solves) {
return 1;
} else {
if (a.time < b.time) {
return -1;
} else if (a.time > b.time) {
return 1;
} else {
return 0;
}
}
})
};
})
};