sync: import all visible activities in parallel
The bulk import loop awaited importActivity() one row at a time, so with N visible activities the browser paid N sequential round trips (plus each activity's own processing time) back to back. Requests now fire concurrently via Promise.allSettled, with the button label updating live as each one finishes. The backend already handles concurrent activity imports fine -- each goes through its own DB transaction and its own geo::crossings_for_track query -- so this is purely a client-side change.
This commit is contained in:
parent
a0fe9c88ce
commit
086ad73ebe
1 changed files with 16 additions and 8 deletions
24
src/main.rs
24
src/main.rs
|
|
@ -663,18 +663,26 @@ if (importAllForm) {
|
|||
if (button) button.disabled = true;
|
||||
|
||||
let done = 0;
|
||||
for (const row of rows) {
|
||||
const ok = await importActivity(
|
||||
row.dataset.athleteId,
|
||||
row.dataset.activityId,
|
||||
row
|
||||
);
|
||||
if (ok) done += 1;
|
||||
const updateLabel = () => {
|
||||
if (button) {
|
||||
button.textContent =
|
||||
'Importiere … (' + done + '/' + rows.length + ')';
|
||||
}
|
||||
}
|
||||
};
|
||||
updateLabel();
|
||||
|
||||
await Promise.allSettled(
|
||||
rows.map((row) =>
|
||||
importActivity(
|
||||
row.dataset.athleteId,
|
||||
row.dataset.activityId,
|
||||
row
|
||||
).then((ok) => {
|
||||
if (ok) done += 1;
|
||||
updateLabel();
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
if (button) {
|
||||
button.textContent =
|
||||
|
|
|
|||
Loading…
Reference in a new issue