Skip to content

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

wip

Edward Cuif1cfaabcd4e9
diff --git a/server/src/services/import/workers/dataInsertWorker.ts b/server/src/services/import/workers/dataInsertWorker.ts
index 41b8932b9..46fa60fe1 100644
--- a/server/src/services/import/workers/dataInsertWorker.ts
+++ b/server/src/services/import/workers/dataInsertWorker.ts
@@ -5,20 +5,20 @@ import { clickhouse } from "../../../db/clickhouse/clickhouse.js";
import { Job } from "pg-boss";
import { ImportStatusManager } from "../importStatusManager.js";
+const getImportDataMapping = (source: string) => {
+ switch (source) {
+ case "umami":
+ return UmamiImportMapper;
+ default:
+ throw new Error(`Unsupported import source: ${source}`);
+ }
+}
+
export async function registerDataInsertWorker() {
await boss.work(DATA_INSERT_QUEUE, { batchSize: 1, pollingIntervalSeconds: 2 }, async ([ job ]: Job<DataInsertJob>[]) => {
const { site, importId, source, chunk } = job.data;
try {
- const getImportDataMapping = (source: string) => {
- switch (source) {
- case "umami":
- return UmamiImportMapper;
- default:
- throw new Error(`Unsupported import source: ${source}`);
- }
- }
-
const dataMapper = getImportDataMapping(source);
const transformedRecords = dataMapper.transform(chunk, site, importId);
diff --git a/server/src/services/import/workers/importCompletionWorker.ts b/server/src/services/import/workers/importCompletionWorker.ts
index bd928ef13..dce68931a 100644
--- a/server/src/services/import/workers/importCompletionWorker.ts
+++ b/server/src/services/import/workers/importCompletionWorker.ts
@@ -13,6 +13,7 @@ export async function registerImportCompletionWorker() {
} catch (error) {
console.error(`Failed to mark import ${importId} as completed:`, error);
await ImportStatusManager.updateStatus(importId, "failed", "Failed to complete import");
+ throw error;
}
});
}