Add background bulk import for Komoot

Replace the per-tour import UI with a fire-and-forget background job:

- Add `import_batches` DB table tracking status, found/imported/duplicate counts
- Add `runKomootBulkImport` server function that pages all Komoot tours,
  fetches GPX, creates activities, and deduplicates via sync_imports
- Add `komoot-bulk-import` pg-boss job registered at server startup
- Add POST /api/sync/komoot/import to enqueue the job
- Add GET /api/sync/komoot/import-status to return the latest batch
- Replace the Komoot import page with a progress UI that polls every 2s
  while a batch is running and shows found/imported/skipped counts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-05-23 18:19:10 +02:00
parent 386867ef6a
commit 5ff7af8a81
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9
10 changed files with 442 additions and 211 deletions

View file

@ -143,7 +143,9 @@ server.listen(port, async () => {
// notifications wired up would silently drop fan-out enqueues.
const { notificationsFanoutJob } = await import("./app/jobs/notifications-fanout.ts");
const { notificationsPurgeJob } = await import("./app/jobs/notifications-purge.ts");
jobs.push(notificationsFanoutJob, notificationsPurgeJob);
const { komootBulkImportJob } = await import("./app/jobs/komoot-bulk-import.ts");
// eslint-disable-next-line @typescript-eslint/no-explicit-any
jobs.push(notificationsFanoutJob, notificationsPurgeJob, komootBulkImportJob as any);
const boss = createBoss(process.env.DATABASE_URL ?? "postgres://trails:trails@localhost:5432/trails");
await startWorker(boss, jobs);