Fixed counting bug

ref #94
This commit is contained in:
Nicolai Ort 2021-03-26 16:05:49 +01:00
parent 4b3d38b05b
commit f5c1ec9939
2 changed files with 13 additions and 4 deletions

View File

@ -150,7 +150,6 @@
let count = 0; let count = 0;
const current_cards = await RunnerCardService.runnerCardControllerGetAll(); const current_cards = await RunnerCardService.runnerCardControllerGetAll();
for await (const t of generate_teams) { for await (const t of generate_teams) {
count++;
const runners = await RunnerTeamService.runnerTeamControllerGetRunners( const runners = await RunnerTeamService.runnerTeamControllerGetRunners(
t.id t.id
); );
@ -216,18 +215,29 @@
duration: -1, duration: -1,
}).showToast(); }).showToast();
let count = 0; let count = 0;
const current_cards = await RunnerCardService.runnerCardControllerGetAll();
for await (const o of generate_orgs) { for await (const o of generate_orgs) {
const runners = await RunnerOrganizationService.runnerOrganizationControllerGetRunners( const runners = await RunnerOrganizationService.runnerOrganizationControllerGetRunners(
o.id o.id
); );
let cards = [];
for (let runner of runners) {
let card = current_cards.find((c) => c.runner?.id == runner.id);
if (!card) {
card = await RunnerCardService.runnerCardControllerPost({
runner: runner.id,
});
}
cards.push(card);
}
fetch( fetch(
`${config.baseurl}/documents/contracts?locale=${locale}&download=true&key=${config.documentserver_key}`, `${config.baseurl}/documents/cards?locale=${locale}&download=true&key=${config.documentserver_key}`,
{ {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
body: JSON.stringify(runners), body: JSON.stringify(cards),
} }
) )
.then((response) => { .then((response) => {

View File

@ -89,7 +89,6 @@
text: $_("generating-pdf"), text: $_("generating-pdf"),
duration: -1, duration: -1,
}).showToast(); }).showToast();
let count = 0;
for await (const o of generate_orgs) { for await (const o of generate_orgs) {
const runners = await RunnerOrganizationService.runnerOrganizationControllerGetRunners( const runners = await RunnerOrganizationService.runnerOrganizationControllerGetRunners(
o.id o.id