sorting multiple scores correction in Leaderboard
This commit is contained in:
parent
6e54e070d0
commit
b8d1434040
@ -20,7 +20,7 @@ const Leaderboard = (props) => {
|
||||
const [submitterSorted, setSubmitterSorted] = React.useState(false);
|
||||
const [entriesSorted, setEntriesSorted] = React.useState(false);
|
||||
const [whenSorted, setWhenSorted] = React.useState(false);
|
||||
const [scoreSorted, setScoreSorted] = React.useState(false);
|
||||
const [scoresSorted, setScoresSorted] = React.useState([]);
|
||||
|
||||
React.useEffect(() => {
|
||||
challengeDataRequest(props.challengeName);
|
||||
@ -124,12 +124,16 @@ const Leaderboard = (props) => {
|
||||
break;
|
||||
default:
|
||||
metricIndex = getMetricIndex(elem);
|
||||
if (scoreSorted) {
|
||||
// eslint-disable-next-line no-case-declarations
|
||||
let newScoresSorted = scoresSorted;
|
||||
if (scoresSorted[metricIndex]) {
|
||||
newEntries = newEntries.sort((a, b) => b.evaluations[metricIndex].score - a.evaluations[metricIndex].score);
|
||||
setScoreSorted(false);
|
||||
newScoresSorted[metricIndex] = false;
|
||||
setScoresSorted(newScoresSorted);
|
||||
} else {
|
||||
newEntries = newEntries.sort((a, b) => a.evaluations[metricIndex].score - b.evaluations[metricIndex].score);
|
||||
setScoreSorted(true);
|
||||
newScoresSorted[metricIndex] = true;
|
||||
setScoresSorted(newScoresSorted);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -19,10 +19,10 @@ const MyEntries = (props) => {
|
||||
const [pageNr, setPageNr] = React.useState(1);
|
||||
const [whenSorted, setWhenSorted] = React.useState(false);
|
||||
const [scoresSorted, setScoresSorted] = React.useState([]);
|
||||
/* eslint-disable */
|
||||
|
||||
React.useEffect(() => {
|
||||
challengesRequest();
|
||||
// eslint-disable-next-line
|
||||
}, []);
|
||||
|
||||
const searchQueryHandler = (event) => {
|
||||
@ -38,7 +38,7 @@ const MyEntries = (props) => {
|
||||
}
|
||||
}
|
||||
return metrics;
|
||||
}
|
||||
};
|
||||
|
||||
const nextPage = () => {
|
||||
if (pageNr !== CALC_PAGES(myEntries ? myEntries : [])) {
|
||||
@ -69,7 +69,7 @@ const MyEntries = (props) => {
|
||||
|
||||
const mobileRender = () => {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const sortByUpdate = (elem, i) => {
|
||||
let newEntries = myEntries;
|
||||
@ -86,7 +86,9 @@ const MyEntries = (props) => {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// eslint-disable-next-line no-case-declarations
|
||||
let metricIndex = getPossibleMetrics().indexOf(elem);
|
||||
// eslint-disable-next-line no-case-declarations
|
||||
let newScoresSorted = scoresSorted;
|
||||
if (scoresSorted[metricIndex]) {
|
||||
newEntries = newEntries.sort((a, b) => b.evaluations[elem] - a.evaluations[elem]);
|
||||
|
Loading…
Reference in New Issue
Block a user