daily-hourly-stats.prisma 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. model AdsHourlyStats {
  2. id String @id @map("_id") @default(auto()) @db.ObjectId
  3. adsId String @db.ObjectId
  4. // Hour bucket start time (epoch seconds, GMT+8 aligned in code)
  5. hourStartAt BigInt
  6. clicks BigInt @default(0)
  7. createAt BigInt
  8. updateAt BigInt
  9. @@index([hourStartAt])
  10. @@unique([adsId, hourStartAt])
  11. @@map("adsHourlyStats")
  12. }
  13. model AdsDailyStats {
  14. id String @id @map("_id") @default(auto()) @db.ObjectId
  15. adsId String @db.ObjectId
  16. // Day bucket start time (epoch seconds, GMT+8 aligned in code)
  17. dayStartAt BigInt
  18. clicks BigInt @default(0)
  19. createAt BigInt
  20. updateAt BigInt
  21. @@index([dayStartAt])
  22. @@unique([adsId, dayStartAt])
  23. @@map("adsDailyStats")
  24. }
  25. model ChannelHourlyUserStats {
  26. id String @id @map("_id") @default(auto()) @db.ObjectId
  27. channelId String
  28. // Hour bucket start time (epoch seconds, GMT+8 aligned in code)
  29. hourStartAt BigInt
  30. // Total events in this hour (e.g. login count)
  31. total BigInt @default(0)
  32. // Unique user count (dedup by uid during aggregation)
  33. uniqueUsers BigInt @default(0)
  34. createAt BigInt
  35. updateAt BigInt
  36. @@index([hourStartAt])
  37. @@unique([channelId, hourStartAt])
  38. @@map("channelHourlyUserStats")
  39. }
  40. model ChannelDailyUserStats {
  41. id String @id @map("_id") @default(auto()) @db.ObjectId
  42. channelId String
  43. // Day bucket start time (epoch seconds, GMT+8 aligned in code)
  44. dayStartAt BigInt
  45. total BigInt @default(0)
  46. uniqueUsers BigInt @default(0)
  47. createAt BigInt
  48. updateAt BigInt
  49. @@index([dayStartAt])
  50. @@unique([channelId, dayStartAt])
  51. @@map("channelDailyUserStats")
  52. }