mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-22 10:47:26 +02:00
♻️ Refactor poll view tracking (#1644)
This commit is contained in:
parent
6b914610d9
commit
f05f437b56
13 changed files with 288 additions and 41 deletions
|
@ -62,6 +62,7 @@ model User {
|
|||
participants Participant[]
|
||||
paymentMethods PaymentMethod[]
|
||||
subscription Subscription? @relation("UserToSubscription")
|
||||
pollViews PollView[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
|
@ -167,6 +168,7 @@ model Poll {
|
|||
watchers Watcher[]
|
||||
comments Comment[]
|
||||
votes Vote[]
|
||||
views PollView[]
|
||||
|
||||
@@index([guestId])
|
||||
@@map("polls")
|
||||
|
@ -284,6 +286,23 @@ model Comment {
|
|||
@@map("comments")
|
||||
}
|
||||
|
||||
model PollView {
|
||||
id String @id @default(cuid())
|
||||
pollId String @map("poll_id")
|
||||
ipAddress String? @map("ip_address")
|
||||
userId String? @map("user_id")
|
||||
userAgent String? @map("user_agent")
|
||||
viewedAt DateTime @default(now()) @map("viewed_at")
|
||||
|
||||
poll Poll @relation(fields: [pollId], references: [id], onDelete: Cascade)
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
|
||||
|
||||
@@index([pollId], type: Hash)
|
||||
@@index([userId], type: Hash)
|
||||
@@index([viewedAt])
|
||||
@@map("poll_views")
|
||||
}
|
||||
|
||||
model VerificationToken {
|
||||
identifier String @db.Citext
|
||||
token String @unique
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue