Files
livedash-node/prisma/schema.prisma
Max Kowalski 8c43a35632 feat: Enhance session processing and metrics
- Updated session processing commands in documentation for clarity.
- Removed transcript content fetching from session processing, allowing on-demand retrieval.
- Improved session metrics calculations and added new metrics for dashboard.
- Refactored processing scheduler to handle sessions in parallel with concurrency limits.
- Added manual trigger API for processing unprocessed sessions with admin checks.
- Implemented scripts for fetching and parsing transcripts, checking transcript content, and testing processing status.
- Updated Prisma schema to enforce default values for processed sessions.
- Added error handling and logging improvements throughout the processing workflow.
2025-06-26 17:12:42 +02:00

75 lines
2.5 KiB
Plaintext

// Database schema, one company = one org, linked to users and CSV config
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
url = "file:./dev.db"
}
model Company {
id String @id @default(uuid())
name String
csvUrl String // where to fetch CSV
csvUsername String? // for basic auth
csvPassword String?
sentimentAlert Float? // e.g. alert threshold for negative chats
dashboardOpts String? // JSON blob for per-company dashboard preferences
users User[]
sessions Session[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model User {
id String @id @default(uuid())
email String @unique
password String // hashed, use bcrypt
company Company @relation(fields: [companyId], references: [id])
companyId String
role String // 'admin' | 'user' | 'auditor'
resetToken String?
resetTokenExpiry DateTime?
}
model Session {
id String @id
company Company @relation(fields: [companyId], references: [id])
companyId String
startTime DateTime
endTime DateTime
ipAddress String?
country String?
language String?
messagesSent Int?
sentiment Float? // Original sentiment score (float)
sentimentCategory String? // "positive", "neutral", "negative" from OpenAPI
escalated Boolean?
forwardedHr Boolean?
fullTranscriptUrl String?
avgResponseTime Float?
tokens Int?
tokensEur Float?
category String?
initialMsg String?
processed Boolean @default(false) // Flag for post-processing status
questions String? // JSON array of questions asked by user
summary String? // Brief summary of the conversation
messages Message[] // Relation to parsed messages
createdAt DateTime @default(now())
}
model Message {
id String @id @default(uuid())
session Session @relation(fields: [sessionId], references: [id], onDelete: Cascade)
sessionId String
timestamp DateTime // When the message was sent
role String // "User", "Assistant", "System", etc.
content String // The message content
order Int // Order within the conversation (0, 1, 2, ...)
createdAt DateTime @default(now())
@@index([sessionId, order]) // Index for efficient ordering queries
}