Skip to content

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

Fix import status typing

Edward Cuic91ed81011a4
diff --git a/server/src/db/postgres/schema.ts b/server/src/db/postgres/schema.ts
index ee1f30858..48581bd24 100644
--- a/server/src/db/postgres/schema.ts
+++ b/server/src/db/postgres/schema.ts
@@ -9,6 +9,7 @@ import {
foreignKey,
unique,
bigint,
+ pgEnum,
} from "drizzle-orm/pg-core";
// User table
@@ -254,6 +255,17 @@ export const goals = pgTable(
]
);
+const importSourceEnum = pgEnum("import_source_enum", [
+ "umami",
+]);
+
+const importStatusEnum = pgEnum("import_status_enum", [
+ "pending",
+ "processing",
+ "completed",
+ "failed",
+]);
+
// Import status table for tracking data import progress
export const importStatus = pgTable(
"import_status",
@@ -261,14 +273,14 @@ export const importStatus = pgTable(
importId: text("import_id").primaryKey().notNull(),
siteId: integer("site_id").notNull(),
organizationId: text("organization_id").notNull(),
- source: text("source").notNull(),
- status: text("status").notNull().default("pending"),
+ source: importSourceEnum("source").notNull(),
+ status: importStatusEnum("status").notNull().default("pending"),
totalRows: integer("total_rows"),
- processedRows: integer("processed_rows").default(0),
- chunksCompleted: integer("chunks_completed").default(0),
+ processedRows: integer("processed_rows").notNull().default(0),
+ chunksCompleted: integer("chunks_completed").notNull().default(0),
totalChunks: integer("total_chunks"),
errorMessage: text("error_message"),
- startedAt: timestamp("started_at").defaultNow(),
+ startedAt: timestamp("started_at").notNull().defaultNow(),
completedAt: timestamp("completed_at"),
fileName: text("file_name").notNull(),
fileSize: bigint("file_size", { mode: "number" }).notNull(),
diff --git a/server/src/types/import.ts b/server/src/types/import.ts
index c0a5465a2..9beb535d8 100644
--- a/server/src/types/import.ts
+++ b/server/src/types/import.ts
@@ -23,21 +23,21 @@ export interface ImportMapper<T> {
}
export interface ImportStatus {
- import_id: string;
- site_id: string;
- organization: string;
+ importId: string;
+ siteId: number;
+ organizationId: string;
source: "umami";
status: "pending" | "processing" | "completed" | "failed";
- total_rows?: number;
- processed_rows: number;
- chunks_completed: number;
- total_chunks?: number;
- error_message?: string;
- started_at: Date;
- completed_at?: Date;
- file_name: string;
- file_size: number;
- created_by: string; // user_id
+ totalRows: number | null;
+ processedRows: number;
+ chunksCompleted: number;
+ totalChunks: number | null;
+ errorMessage: string | null;
+ startedAt: Date;
+ completedAt: Date | null;
+ fileName: string;
+ fileSize: number;
+ createdBy: string; // user_id
}
interface RybbitEvent {