refactor(analyitics): finished analyitics as a base
This commit is contained in:
21
backend/db/schema/analytics.schema.ts
Normal file
21
backend/db/schema/analytics.schema.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { integer, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
|
||||
|
||||
export const analytics = pgTable("analytics", {
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
|
||||
createdAt: timestamp("created_at").defaultNow().notNull(),
|
||||
|
||||
method: text("method").notNull(),
|
||||
routePattern: text("route_pattern").notNull(),
|
||||
actualPath: text("actual_path").notNull(),
|
||||
|
||||
statusCode: integer("status_code").notNull(),
|
||||
durationMs: integer("duration_ms").notNull(),
|
||||
|
||||
module: text("module"),
|
||||
userId: text("user_id"),
|
||||
userEmail: text("user_email"),
|
||||
|
||||
ipAddress: text("ip_address"),
|
||||
userAgent: text("user_agent"),
|
||||
});
|
||||
33
backend/db/schema/dailyAnalytics.schema.ts
Normal file
33
backend/db/schema/dailyAnalytics.schema.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import {
|
||||
date,
|
||||
integer,
|
||||
pgTable,
|
||||
text,
|
||||
timestamp,
|
||||
uuid,
|
||||
} from "drizzle-orm/pg-core";
|
||||
|
||||
export const analyticsDaily = pgTable("analytics_daily", {
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
|
||||
businessDate: date("business_date").notNull(),
|
||||
|
||||
method: text("method").notNull(),
|
||||
routePattern: text("route_pattern").notNull(),
|
||||
module: text("module").notNull(),
|
||||
|
||||
totalHits: integer("total_hits").notNull(),
|
||||
uniqueUsers: integer("unique_users").notNull(),
|
||||
|
||||
successCount: integer("success_count").notNull(),
|
||||
errorCount: integer("error_count").notNull(),
|
||||
|
||||
avgDurationMs: integer("avg_duration_ms").notNull(),
|
||||
maxDurationMs: integer("max_duration_ms").notNull(),
|
||||
|
||||
firstHitAt: timestamp("first_hit_at").notNull(),
|
||||
lastHitAt: timestamp("last_hit_at").notNull(),
|
||||
|
||||
createdAt: timestamp("created_at").defaultNow().notNull(),
|
||||
updatedAt: timestamp("updated_at").defaultNow().notNull(),
|
||||
});
|
||||
Reference in New Issue
Block a user