Files
modstagram-back/models/ExploreInteractionModel.js
payacom 3f416a7a60 full
2026-08-31 20:45:41 +03:30

73 lines
1.7 KiB
JavaScript

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', 'shop_product', 'academy_course', 'billboard'],
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', 'shop_product', 'billboard'],
default: 'image'
},
action: {
type: String,
enum: [
'view',
'profile_visit',
'share',
'like',
'comment',
'offer',
'watch_complete',
'skip',
'dwell'
],
default: 'view'
},
dwellMs: {
type: Number,
default: null
},
/**
* Snapshot of the viewer's own profile province/city at view time (only when they've
* set one and enabled show_location) — the only geography signal available without
* IP-geolocation or live GPS capture, neither of which exists in this codebase. This
* is "where the viewer is from", not "where they physically were when they viewed".
*/
viewerCountry: {
type: Object,
default: null
},
viewerProvince: {
type: Object,
default: null
},
viewerCity: {
type: Object,
default: null
}
})
exploreInteractionSchema.index({ viewerId: 1, createdAt: -1 })
exploreInteractionSchema.plugin(timestamp)
module.exports = mongoose.model('ExploreInteraction', exploreInteractionSchema)