ads-click-history.prisma 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. model AdsClickHistory {
  2. id String @id @map("_id") @default(auto()) @db.ObjectId
  3. adsId String @db.ObjectId // 广告 ID
  4. adType String // 广告类型 (BANNER, STARTUP, etc.)
  5. adsModuleId String @db.ObjectId // 广告模块 ID
  6. uid String // 用户设备码 (from JWT)
  7. ip String // 点击 IP
  8. appVersion String? // 客户端版本 (optional)
  9. os String? // iOS / Android / Web (optional)
  10. channelId String // 用户自带渠道 Id (required)
  11. machine String // 客户端提供 : 设备的信息,品牌及系统版本什么的 (required)
  12. clickAt BigInt // 点击时间 (epoch millis)
  13. // Indexes for common queries:
  14. // 1. Query all clicks for a specific ad
  15. @@index([adsId, clickAt])
  16. // 2. Query clicks by user (device)
  17. @@index([uid, clickAt])
  18. // 3. Query clicks by channel + user (for reporting)
  19. @@index([channelId, uid, clickAt])
  20. // 4. Query clicks by IP (fraud detection)
  21. @@index([ip, clickAt])
  22. // 5. Query clicks by ad type
  23. @@index([adType, clickAt])
  24. // 6. Global stats by time
  25. @@index([clickAt])
  26. @@map("adsClickHistory")
  27. }