mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 09:52:09 +01:00
- Added processingScheduler.js and processingScheduler.ts to handle session transcript processing using OpenAI API. - Implemented a new scheduler (scheduler.js and schedulers.ts) for refreshing sessions every 15 minutes. - Updated Prisma migrations to add new fields for processed sessions, including questions, sentimentCategory, and summary. - Created scripts (process_sessions.mjs and process_sessions.ts) for manual processing of unprocessed sessions. - Enhanced server.js and server.mjs to initialize schedulers on server start.
62 lines
2.0 KiB
Plaintext
62 lines
2.0 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?
|
|
transcriptContent String? // Added to store the fetched transcript
|
|
avgResponseTime Float?
|
|
tokens Int?
|
|
tokensEur Float?
|
|
category String?
|
|
initialMsg String?
|
|
processed Boolean? // Flag for post-processing status
|
|
questions String? // JSON array of questions asked by user
|
|
summary String? // Brief summary of the conversation
|
|
createdAt DateTime @default(now())
|
|
}
|