| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- model AdClickEvents {
- id String @id @map("_id") @default(auto()) @db.ObjectId
- uid String // 设备码(from JWT / device)
- adsId String? @db.ObjectId // 广告 ID mongo objectId
- adId Int? @db.Int // 广告 ID 自增数字唯一 ID
- adType String? // 广告类型 (BANNER/STARTUP/...)
- clickedAt BigInt // 点击时间 (epoch)
- ip String // 点击 IP
- channelId String // 用户自带渠道 Id (required)
- machine String? // 客户端提供 : 设备的信息,品牌及系统版本什么的 (required)
- createAt BigInt // 记录创建时间
- updateAt BigInt // 记录更新时间
- // Query helpers
- // 1. 查某广告的点击列表
- @@index([adId, clickedAt])
- // 2. 查某设备的点击轨迹
- @@index([uid, clickedAt])
- // 3. 按渠道+设备分析(报表)
- @@index([channelId, uid, clickedAt])
- // 4. 按广告类型/时间分析
- @@index([adType, clickedAt])
- // 5. 全局按时间片
- @@index([clickedAt])
- @@map("adClickEvents")
- }
- model ProcessedMessage {
- id String @id @map("_id") @default(auto()) @db.ObjectId
- messageId String @unique // 去重用的唯一消息 ID
- eventType String // 事件类型(如 stats.ad.click)
- processedAt BigInt // 处理时间 (epoch seconds)
- createdAt BigInt // 创建时间 (epoch seconds)
- @@map("processedMessages")
- }
- model AdsGlobalStats {
- id String @id @map("_id") @default(auto()) @db.ObjectId
- adsId String @unique @db.ObjectId // ✅ required + unique
- // adId Int? @db.Int // 广告 ID 自增数字唯一 ID
- impressions BigInt @default(0) // 曝光总数
- clicks BigInt @default(0) // 点击总数
- firstSeenAt BigInt // 首次出现时间 (epoch)
- lastSeenAt BigInt // 最后活跃时间 (epoch)
- computedCtr Float @default(0) // 计算的点击率 (clicks/impressions)
- computedPopularity Float @default(0) // 计算的热度得分
- computedRecency Float @default(0) // 计算的时效性得分
- computedScore Float @default(0) // 综合得分
- createAt BigInt // 创建时间 (epoch)
- updateAt BigInt // 更新时间 (epoch)
- @@index([computedScore])
- @@index([computedRecency, computedScore])
- @@index([computedCtr])
- @@index([lastSeenAt])
- @@map("adsGlobalStats")
- }
|