[web] Sort scoreboard
This commit is contained in:
parent
149037cf7d
commit
83b5d75ed1
@ -14,75 +14,93 @@ export const load = (async () => {
|
|||||||
problems: contest.problems.map((problem) => {
|
problems: contest.problems.map((problem) => {
|
||||||
return { id: problem.id, friendlyName: problem.friendlyName };
|
return { id: problem.id, friendlyName: problem.friendlyName };
|
||||||
}),
|
}),
|
||||||
teams: contest.teams.map((team) => {
|
teams: contest.teams
|
||||||
return {
|
.map((team) => {
|
||||||
name: team.name,
|
return {
|
||||||
solves: team.submissions.filter((submission) => {
|
name: team.name,
|
||||||
return submission.contestId === contest.id && submission.state === 'Correct';
|
solves: team.submissions.filter((submission) => {
|
||||||
}).length,
|
|
||||||
time: (() => {
|
|
||||||
const correctSubmissions = team.submissions.filter((submission) => {
|
|
||||||
return submission.contestId === contest.id && submission.state === 'Correct';
|
return submission.contestId === contest.id && submission.state === 'Correct';
|
||||||
});
|
}).length,
|
||||||
const penaltyTime =
|
time: (() => {
|
||||||
team.submissions.filter((submission) => {
|
const correctSubmissions = team.submissions.filter((submission) => {
|
||||||
return (
|
return submission.contestId === contest.id && submission.state === 'Correct';
|
||||||
submission.contestId === contest.id &&
|
});
|
||||||
submission.state === 'Incorrect' &&
|
const penaltyTime =
|
||||||
correctSubmissions.find((correct) => {
|
team.submissions.filter((submission) => {
|
||||||
return correct.problemId === submission.problemId;
|
return (
|
||||||
})
|
submission.contestId === contest.id &&
|
||||||
);
|
submission.state === 'Incorrect' &&
|
||||||
}).length * 10;
|
correctSubmissions.find((correct) => {
|
||||||
let time = penaltyTime;
|
return correct.problemId === submission.problemId;
|
||||||
correctSubmissions.forEach((correctSubmission) => {
|
})
|
||||||
const gradedAt = correctSubmission.gradedAt!.valueOf();
|
);
|
||||||
const min = (gradedAt - contest.startTime!.valueOf()) / 60000;
|
}).length * 10;
|
||||||
time += min;
|
let time = penaltyTime;
|
||||||
});
|
correctSubmissions.forEach((correctSubmission) => {
|
||||||
return time;
|
const gradedAt = correctSubmission.gradedAt!.valueOf();
|
||||||
})(),
|
const min = (gradedAt - contest.startTime!.valueOf()) / 60000;
|
||||||
problems: contest.problems.map((problem) => {
|
time += min;
|
||||||
return {
|
});
|
||||||
id: problem.id,
|
return time;
|
||||||
attempts: team.submissions.filter((submission) => {
|
})(),
|
||||||
return (
|
problems: contest.problems.map((problem) => {
|
||||||
submission.contestId === contest.id &&
|
return {
|
||||||
submission.problemId === problem.id &&
|
id: problem.id,
|
||||||
(submission.state === 'Correct' || submission.state === 'Incorrect')
|
attempts: team.submissions.filter((submission) => {
|
||||||
);
|
|
||||||
}).length,
|
|
||||||
graphic: team.submissions.find((submission) => {
|
|
||||||
return (
|
|
||||||
submission.contestId === contest.id &&
|
|
||||||
submission.problemId === problem.id &&
|
|
||||||
(submission.state === 'Correct' || submission.state === 'Incorrect')
|
|
||||||
);
|
|
||||||
})
|
|
||||||
? team.submissions.find((submission) => {
|
|
||||||
return submission.problemId === problem.id && submission.state === 'Correct';
|
|
||||||
})
|
|
||||||
? 'correct'
|
|
||||||
: 'incorrect'
|
|
||||||
: null,
|
|
||||||
min: (() => {
|
|
||||||
const correctSubmission = team.submissions.find((submission) => {
|
|
||||||
return (
|
return (
|
||||||
submission.contestId === contest.id &&
|
submission.contestId === contest.id &&
|
||||||
submission.problemId === problem.id &&
|
submission.problemId === problem.id &&
|
||||||
submission.state === 'Correct'
|
(submission.state === 'Correct' || submission.state === 'Incorrect')
|
||||||
);
|
);
|
||||||
});
|
}).length,
|
||||||
if (correctSubmission) {
|
graphic: team.submissions.find((submission) => {
|
||||||
const gradedAt = correctSubmission.gradedAt!.valueOf();
|
return (
|
||||||
return (gradedAt - contest.startTime!.valueOf()) / 60000;
|
submission.contestId === contest.id &&
|
||||||
}
|
submission.problemId === problem.id &&
|
||||||
return undefined;
|
(submission.state === 'Correct' || submission.state === 'Incorrect')
|
||||||
})()
|
);
|
||||||
};
|
})
|
||||||
})
|
? team.submissions.find((submission) => {
|
||||||
};
|
return (
|
||||||
})
|
submission.problemId === problem.id && submission.state === 'Correct'
|
||||||
|
);
|
||||||
|
})
|
||||||
|
? 'correct'
|
||||||
|
: 'incorrect'
|
||||||
|
: null,
|
||||||
|
min: (() => {
|
||||||
|
const correctSubmission = team.submissions.find((submission) => {
|
||||||
|
return (
|
||||||
|
submission.contestId === contest.id &&
|
||||||
|
submission.problemId === problem.id &&
|
||||||
|
submission.state === 'Correct'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
if (correctSubmission) {
|
||||||
|
const gradedAt = correctSubmission.gradedAt!.valueOf();
|
||||||
|
return (gradedAt - contest.startTime!.valueOf()) / 60000;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
})()
|
||||||
|
};
|
||||||
|
})
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user