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:
parent
386867ef6a
commit
5ff7af8a81
10 changed files with 442 additions and 211 deletions
|
|
@ -276,6 +276,26 @@ export const syncPushes = journalSchema.table(
|
|||
// row in this change. `acceptedAt` is always set today (auto-accept for
|
||||
// public local profiles); the column stays nullable so federation's Pending
|
||||
// state lands cleanly.
|
||||
export type ImportBatchStatus = "pending" | "running" | "completed" | "failed";
|
||||
|
||||
export const importBatches = journalSchema.table("import_batches", {
|
||||
id: text("id").primaryKey(),
|
||||
userId: text("user_id")
|
||||
.notNull()
|
||||
.references(() => users.id, { onDelete: "cascade" }),
|
||||
connectionId: text("connection_id")
|
||||
.notNull()
|
||||
.references(() => connectedServices.id, { onDelete: "cascade" }),
|
||||
provider: text("provider").notNull(),
|
||||
status: text("status").$type<ImportBatchStatus>().notNull().default("pending"),
|
||||
totalFound: integer("total_found").notNull().default(0),
|
||||
importedCount: integer("imported_count").notNull().default(0),
|
||||
duplicateCount: integer("duplicate_count").notNull().default(0),
|
||||
errorMessage: text("error_message"),
|
||||
startedAt: timestamp("started_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
completedAt: timestamp("completed_at", { withTimezone: true }),
|
||||
});
|
||||
|
||||
export const follows = journalSchema.table("follows", {
|
||||
id: text("id").primaryKey(),
|
||||
followerId: text("follower_id")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue