2022-10-14 11:35:48 +02:00
|
|
|
import {API} from '../utils/globals';
|
|
|
|
import KeyCloakService from '../services/KeyCloakService';
|
|
|
|
|
2022-11-09 17:49:57 +01:00
|
|
|
const getMyEntries = (challengeName, setDataOriginalState, setDataState, setLoadingState) => {
|
2022-10-14 11:35:48 +02:00
|
|
|
fetch(`${API}/challenge-my-submissions/${challengeName}`, {
|
|
|
|
headers: {'Authorization': `Bearer ${KeyCloakService.getToken()}`}
|
|
|
|
})
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
2022-11-09 17:49:57 +01:00
|
|
|
setDataOriginalState(data);
|
|
|
|
let item = {};
|
|
|
|
let result = [];
|
|
|
|
let tests = data.tests;
|
|
|
|
for (let submission of data.submissions) {
|
|
|
|
for (let evaluation of submission.evaluations) {
|
|
|
|
item = {
|
|
|
|
...item,
|
|
|
|
evaluations: {
|
|
|
|
...item.evaluations,
|
|
|
|
[`${evaluation.test.metric}.${evaluation.test.name}`]: evaluation.score
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
for (let test of tests) {
|
|
|
|
if (!Object.hasOwn(item.evaluations, `${test.metric}.${test.name}`)) {
|
|
|
|
item = {
|
|
|
|
...item,
|
|
|
|
evaluations: {
|
|
|
|
...item.evaluations,
|
|
|
|
[`${test.metric}.${test.name}`]: '-1'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
item = {
|
|
|
|
...item,
|
|
|
|
id: submission.id,
|
|
|
|
submitter: submission.submitter,
|
|
|
|
when: submission.when,
|
|
|
|
};
|
|
|
|
result.push(item);
|
|
|
|
item = {};
|
|
|
|
}
|
|
|
|
setDataState(result);
|
2022-10-19 17:48:04 +02:00
|
|
|
setLoadingState(false);
|
2022-10-14 11:35:48 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export default getMyEntries;
|