From 086ad73ebe454073a5aa989a88d49a4350a8f127 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 13 Aug 2026 09:46:43 +0000 Subject: [PATCH] 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. --- src/main.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index d124d0b..8c4290c 100644 --- a/src/main.rs +++ b/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 =