mirror of
https://github.com/System-End/nephthys.git
synced 2026-04-19 22:05:12 +00:00
* Rename tags to team tags * Add a TagType enum with TEAM and QUESTION options * Ticket#questionTag exists now * Revert "Add a TagType enum with TEAM and QUESTION options" This reverts commit c9a17f4003aa2ce470f82810ac031fe83325f3d6. * Add a new QuestionTag model * Add another dropdown to the backend msg * create tag => create team tag * Add creating tags (from the backend channel) * Create a single function for sending the backend message Previously this code was duplicated across 2 places, making it inconsistent * Rename a bunch of files; implement upating question tags on tickets * Add a log! * Fix ticket tag dropdowns in old msgs * Auto-select the current question tag when a backend msg is posted * Update backend message with the current tag * Allow clearing the question tag * Dynamically get question tag list * Document question tags * typo * Change some log msgs to debug * Only make the DB call if current_question_tag_id is present * Remove unused variable * Add createdAt to QuestionTag * Ensure "reopened by [user]" is preserved when backend message is edited
129 lines
3.3 KiB
Text
129 lines
3.3 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[]
|
|
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?
|
|
|
|
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?
|
|
|
|
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])
|
|
}
|