flykup_model_development 3.1.7 → 3.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,35 +1,53 @@
|
|
|
1
1
|
import mongoose, { Schema, model } from 'mongoose';
|
|
2
2
|
|
|
3
3
|
const productInteractionSchema = new mongoose.Schema({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
4
|
+
product: { type: mongoose.Schema.Types.ObjectId, ref: 'Product', required: true },
|
|
5
|
+
user: { type: mongoose.Schema.Types.ObjectId, ref: 'User', index: true },
|
|
6
|
+
seller: { type: mongoose.Schema.Types.ObjectId, ref: 'Seller', required: true },
|
|
7
|
+
location: {
|
|
8
|
+
city: String,
|
|
9
|
+
region: String,
|
|
10
|
+
country: String
|
|
11
|
+
},
|
|
12
|
+
platform: { type: String, enum: ['web', 'mobile', 'unknown'], default: 'mobile' },
|
|
13
|
+
device: { type: String, enum: ['mobile', 'desktop', 'tablet', 'other'] },
|
|
14
|
+
browser: String,
|
|
15
|
+
os: String,
|
|
16
|
+
ip: { type: String, required: true },
|
|
17
|
+
isIndianRegion: { type: Boolean, default: false },
|
|
18
|
+
rating: {
|
|
19
|
+
type: Number,
|
|
20
|
+
min: 1,
|
|
21
|
+
max: 5,
|
|
22
|
+
validate: {
|
|
23
|
+
validator: Number.isInteger,
|
|
24
|
+
message: '{VALUE} is not an integer value'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
review: {
|
|
28
|
+
type: String,
|
|
29
|
+
maxlength: 500
|
|
30
|
+
},
|
|
31
|
+
viewCount: { type: Number, default: 1 },
|
|
32
|
+
// NEW: Trust signals tracking
|
|
33
|
+
trustSignals: {
|
|
34
|
+
reviewViews: { type: Number, default: 0 }, // How many times user viewed reviews
|
|
35
|
+
reviewViewDuration: { type: Number, default: 0 }, // Total time spent on reviews (seconds)
|
|
36
|
+
comparisonViews: { type: Number, default: 0 }, // How many times user compared with other products
|
|
37
|
+
priceCheckCount: { type: Number, default: 0 }, // How many times user checked pricing
|
|
38
|
+
lastTrustSignalAt: { type: Date } // When the last trust signal was recorded
|
|
39
|
+
},
|
|
40
|
+
// NEW: Engagement status for sellers
|
|
41
|
+
engagementStatus: {
|
|
42
|
+
type: String,
|
|
43
|
+
enum: ['new', 'interested', 'hesitant', 'contacted', 'converted'],
|
|
44
|
+
default: 'new'
|
|
45
|
+
},
|
|
46
|
+
sellerNotes: [{
|
|
47
|
+
note: String,
|
|
48
|
+
createdAt: { type: Date, default: Date.now },
|
|
49
|
+
updatedAt: { type: Date, default: Date.now }
|
|
50
|
+
}]
|
|
33
51
|
}, { timestamps: true });
|
|
34
52
|
|
|
35
53
|
// Ensures a user's view is counted only once per product
|
|
@@ -41,3 +59,50 @@ productInteractionSchema.index({ createdAt: -1 });
|
|
|
41
59
|
// Safe export to prevent OverwriteModelError
|
|
42
60
|
const ProductInteraction = mongoose.models.ProductInteraction || mongoose.model('ProductInteraction', productInteractionSchema);
|
|
43
61
|
export default ProductInteraction;
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
// import mongoose, { Schema, model } from 'mongoose';
|
|
67
|
+
|
|
68
|
+
// const productInteractionSchema = new mongoose.Schema({
|
|
69
|
+
// product: { type: mongoose.Schema.Types.ObjectId, ref: 'Product', required: true },
|
|
70
|
+
// user: { type: mongoose.Schema.Types.ObjectId, ref: 'User', index: true },
|
|
71
|
+
// seller: { type: mongoose.Schema.Types.ObjectId, ref: 'Seller', required: true },
|
|
72
|
+
// location: {
|
|
73
|
+
// city: String,
|
|
74
|
+
// region: String,
|
|
75
|
+
// country: String
|
|
76
|
+
// },
|
|
77
|
+
// // --- NEW FIELD ---
|
|
78
|
+
// platform: { type: String, enum: ['web', 'mobile', 'unknown'], default: 'mobile' },
|
|
79
|
+
// device: { type: String, enum: ['mobile', 'desktop', 'tablet', 'other'] },
|
|
80
|
+
// browser: String,
|
|
81
|
+
// os: String,
|
|
82
|
+
// ip: { type: String, required: true },
|
|
83
|
+
// isIndianRegion: { type: Boolean, default: false },
|
|
84
|
+
// rating: {
|
|
85
|
+
// type: Number,
|
|
86
|
+
// min: 1,
|
|
87
|
+
// max: 5,
|
|
88
|
+
// validate: {
|
|
89
|
+
// validator: Number.isInteger,
|
|
90
|
+
// message: '{VALUE} is not an integer value'
|
|
91
|
+
// }
|
|
92
|
+
// },
|
|
93
|
+
// review: {
|
|
94
|
+
// type: String,
|
|
95
|
+
// maxlength: 500
|
|
96
|
+
// },
|
|
97
|
+
// viewCount: { type: Number, default: 1 }
|
|
98
|
+
// }, { timestamps: true });
|
|
99
|
+
|
|
100
|
+
// // Ensures a user's view is counted only once per product
|
|
101
|
+
// productInteractionSchema.index({ product: 1, user: 1 }, { unique: true, partialFilterExpression: { user: { $exists: true } } });
|
|
102
|
+
|
|
103
|
+
// // Additional indexes for performance
|
|
104
|
+
// productInteractionSchema.index({ createdAt: -1 });
|
|
105
|
+
|
|
106
|
+
// // Safe export to prevent OverwriteModelError
|
|
107
|
+
// const ProductInteraction = mongoose.models.ProductInteraction || mongoose.model('ProductInteraction', productInteractionSchema);
|
|
108
|
+
// export default ProductInteraction;
|
|
@@ -167,11 +167,31 @@ const ShoppableVideoSchema = new Schema(
|
|
|
167
167
|
type: Number,
|
|
168
168
|
default: 0
|
|
169
169
|
},
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
170
|
+
// Admin blocking fields
|
|
171
|
+
isBlocked: {
|
|
172
|
+
type: Boolean,
|
|
173
|
+
default: false,
|
|
174
|
+
index: true // For efficient queries of blocked videos
|
|
175
|
+
},
|
|
176
|
+
blockedBy: {
|
|
177
|
+
type: Schema.Types.ObjectId,
|
|
178
|
+
ref: 'Admin',
|
|
179
|
+
default: null
|
|
180
|
+
},
|
|
181
|
+
blockReason: {
|
|
182
|
+
type: String,
|
|
183
|
+
default: null,
|
|
184
|
+
trim: true
|
|
185
|
+
},
|
|
186
|
+
blockedAt: {
|
|
187
|
+
type: Date,
|
|
188
|
+
default: null
|
|
189
|
+
},
|
|
190
|
+
isEligibleToPlay: {
|
|
191
|
+
type: Boolean,
|
|
192
|
+
default: false, // Default to true, can be set to false if video is not eligible for playback
|
|
193
|
+
index: true // Index for quick lookups
|
|
194
|
+
}
|
|
175
195
|
},
|
|
176
196
|
{ timestamps: true }
|
|
177
197
|
);
|