mirror of
https://github.com/System-End/nephthys.git
synced 2026-04-19 16:28:16 +00:00
* Add ai-based ticket categorization and you can add tags in the bot homepage * made the CategoryTag model and refactored the code to support it * Implemented the fulfillment reminder to send all open tickets in the past 24h for amber to check them :) * removed the ability to manage categories from the UI/fixed stuff * Fix type error * removed question tags * Re-add question tags to DB schema This is only because we don't have migrations rn so we can't actually delete stuff from the DB --------- Co-authored-by: MMK21Hub <50421330+MMK21Hub@users.noreply.github.com>
145 lines
3.8 KiB
Text
145 lines
3.8 KiB
Text
generator client {
|
|
provider = "prisma-client-py"
|
|
interface = "asyncio"
|
|
recursive_type_depth = 5
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
enum TicketStatus {
|
|
OPEN
|
|
IN_PROGRESS
|
|
CLOSED
|
|
}
|
|
|
|
enum UserType {
|
|
AUTHOR
|
|
HELPER
|
|
OTHER
|
|
}
|
|
|
|
model User {
|
|
id Int @id @unique @default(autoincrement())
|
|
slackId String @unique
|
|
username String? @unique
|
|
admin Boolean @default(false)
|
|
|
|
openedTickets Ticket[] @relation("OpenedTickets")
|
|
closedTickets Ticket[] @relation("ClosedTickets")
|
|
assignedTickets Ticket[] @relation("AssignedTickets")
|
|
reopenedTickets Ticket[] @relation("ReopenedTickets")
|
|
|
|
tagSubscriptions UserTagSubscription[]
|
|
createdCategoryTags CategoryTag[] @relation("CreatedCategoryTags")
|
|
helper Boolean @default(false)
|
|
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model Ticket {
|
|
id Int @id @unique @default(autoincrement())
|
|
title String
|
|
description String
|
|
status TicketStatus @default(OPEN)
|
|
|
|
// TS for the original help message (top of the help thread)
|
|
msgTs String @unique
|
|
// TS for the ticket message in the "backend" tickets channel
|
|
ticketTs String @unique
|
|
|
|
// Messages sent by the bot in the help thread
|
|
userFacingMsgs BotMessage[]
|
|
|
|
lastMsgAt DateTime? @default(now())
|
|
lastMsgBy UserType? @default(AUTHOR)
|
|
|
|
openedBy User @relation("OpenedTickets", fields: [openedById], references: [id])
|
|
openedById Int
|
|
|
|
reopenedBy User? @relation("ReopenedTickets", fields: [reopenedById], references: [id])
|
|
reopenedById Int?
|
|
reopenedAt DateTime?
|
|
|
|
closedBy User? @relation("ClosedTickets", fields: [closedById], references: [id])
|
|
closedById Int?
|
|
closedAt DateTime?
|
|
|
|
assignedTo User? @relation("AssignedTickets", fields: [assignedToId], references: [id])
|
|
assignedToId Int?
|
|
assignedAt DateTime?
|
|
|
|
tagsOnTickets TagsOnTickets[]
|
|
questionTag QuestionTag? @relation("QuestionTagTickets", fields: [questionTagId], references: [id])
|
|
questionTagId Int?
|
|
|
|
categoryTag CategoryTag? @relation("CategoryTagTickets", fields: [categoryTagId], references: [id])
|
|
categoryTagId Int?
|
|
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model QuestionTag {
|
|
id Int @id @unique @default(autoincrement())
|
|
label String @unique
|
|
tickets Ticket[] @relation("QuestionTagTickets")
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
// These tags are team tags
|
|
model Tag {
|
|
id Int @id @unique @default(autoincrement())
|
|
name String @unique
|
|
|
|
ticketsOnTags TagsOnTickets[]
|
|
|
|
userSubscriptions UserTagSubscription[]
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model TagsOnTickets {
|
|
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
|
|
ticketId Int
|
|
tag Tag @relation(fields: [tagId], references: [id], onDelete: Cascade)
|
|
tagId Int
|
|
|
|
assignedAt DateTime @default(now())
|
|
|
|
@@id([ticketId, tagId])
|
|
@@map("tags_on_tickets")
|
|
}
|
|
|
|
model UserTagSubscription {
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId Int
|
|
tag Tag @relation(fields: [tagId], references: [id], onDelete: Cascade)
|
|
tagId Int
|
|
|
|
subscribedAt DateTime @default(now())
|
|
|
|
@@id([userId, tagId])
|
|
@@map("user_tag_subscriptions")
|
|
}
|
|
|
|
model BotMessage {
|
|
id Int @id @unique @default(autoincrement())
|
|
ts String
|
|
channelId String
|
|
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
|
|
ticketId Int
|
|
|
|
@@unique([ts, channelId])
|
|
}
|
|
|
|
model CategoryTag {
|
|
id Int @id @unique @default(autoincrement())
|
|
name String @unique
|
|
tickets Ticket[] @relation("CategoryTagTickets")
|
|
|
|
createdBy User? @relation("CreatedCategoryTags", fields: [createdById], references: [id])
|
|
createdById Int?
|
|
|
|
createdAt DateTime @default(now())
|
|
}
|