Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Fix import progress update

Edward Cuif9dd912b97f1
diff --git a/server/src/lib/importStatus.ts b/server/src/lib/importStatus.ts
index 616bd6f35..125dc606d 100644
--- a/server/src/lib/importStatus.ts
+++ b/server/src/lib/importStatus.ts
@@ -1,5 +1,5 @@
import { db } from "../db/postgres/postgres.js";
-import { eq, desc } from "drizzle-orm";
+import { eq, desc, sql } from "drizzle-orm";
import { importStatus } from "../db/postgres/schema.js";
type SelectImportStatus = typeof importStatus.$inferSelect;
@@ -17,7 +17,8 @@ export class ImportStatusManager {
): Promise<void> {
const completedAt = status === "completed" || status === "failed" ? new Date() : null;
- await db.update(importStatus)
+ await db
+ .update(importStatus)
.set({ status, errorMessage, completedAt })
.where(eq(importStatus.importId, importId));
}
@@ -26,12 +27,11 @@ export class ImportStatusManager {
importId: string,
importedEvents: number,
): Promise<void> {
- const updateData: Partial<InsertImportStatus> = {
- importedEvents,
- };
-
- await db.update(importStatus)
- .set(updateData)
+ await db
+ .update(importStatus)
+ .set({
+ importedEvents: sql`${importStatus.importedEvents} + ${importedEvents}`,
+ })
.where(eq(importStatus.importId, importId));
}