♻️ Refactor poll view tracking (#1644)

This commit is contained in:
Luke Vella 2025-03-28 10:10:46 +00:00 committed by GitHub
parent 6b914610d9
commit f05f437b56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 288 additions and 41 deletions

View file

@ -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