const mongoose = require('mongoose') const timestamp = require('mongoose-timestamp') const exploreInteractionSchema = new mongoose.Schema({ viewerId: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true, index: true }, targetType: { type: String, enum: ['post', 'profile', 'academy'], required: true }, targetId: { type: mongoose.Schema.Types.ObjectId, required: true }, authorId: { type: mongoose.Schema.Types.ObjectId, ref: 'User', default: null }, contentType: { type: String, enum: ['image', 'video', 'academy'], default: 'image' }, action: { type: String, enum: [ 'view', 'profile_visit', 'share', 'like', 'comment', 'offer', 'watch_complete', 'skip', 'dwell' ], default: 'view' }, dwellMs: { type: Number, default: null } }) exploreInteractionSchema.index({ viewerId: 1, createdAt: -1 }) exploreInteractionSchema.plugin(timestamp) module.exports = mongoose.model('ExploreInteraction', exploreInteractionSchema)