Mark-Lasfar commited on
Commit
e87daf2
·
1 Parent(s): 9e2daf5

Add GraphQL

Browse files
Files changed (1) hide show
  1. server.js +12 -9
server.js CHANGED
@@ -4331,10 +4331,11 @@ const userSchema = new mongoose.Schema({
4331
  // ❤️ برونزيات الإعجابات (Post Likes)
4332
  likes: {
4333
  bronze: { type: Boolean, default: false }, // 10 إعجابات
4334
- silver: { type: Boolean, default: false }, // 30 إعجاب
4335
- gold: { type: Boolean, default: false }, // 60 إعجاب
4336
- red: { type: Boolean, default: false }, // 150 إعجاب
4337
  },
 
4338
  // 💬 برونزيات التفاعل (Comments/Replies)
4339
  interaction: {
4340
  bronze: { type: Boolean, default: false }, // 10 ردود
@@ -4689,15 +4690,17 @@ const alsoViewedSchema = new mongoose.Schema({
4689
  }
4690
  });
4691
 
4692
- // ✅ فهارس محسنة
4693
  alsoViewedSchema.index({ targetUserId: 1, viewerId: 1 }, {
4694
  unique: true,
4695
- sparse: true
4696
- });
4697
- alsoViewedSchema.index({ targetUserId: 1, viewerIp: 1 }, {
4698
- unique: true,
4699
- sparse: true
4700
  });
 
 
 
 
 
4701
  alsoViewedSchema.index({ targetUserId: 1, viewedAt: -1 });
4702
 
4703
  const AlsoViewed = mongoose.model('AlsoViewed', alsoViewedSchema);
 
4331
  // ❤️ برونزيات الإعجابات (Post Likes)
4332
  likes: {
4333
  bronze: { type: Boolean, default: false }, // 10 إعجابات
4334
+ red: { type: Boolean, default: false }, // 128 إعجاب
4335
+ silver: { type: Boolean, default: false }, // 512 إعجاب
4336
+ gold: { type: Boolean, default: false }, // 4096 إعجاب
4337
  },
4338
+
4339
  // 💬 برونزيات التفاعل (Comments/Replies)
4340
  interaction: {
4341
  bronze: { type: Boolean, default: false }, // 10 ردود
 
4690
  }
4691
  });
4692
 
4693
+ // ✅ فهارس محسنة (من غير تكرار)
4694
  alsoViewedSchema.index({ targetUserId: 1, viewerId: 1 }, {
4695
  unique: true,
4696
+ sparse: true,
4697
+ partialFilterExpression: { viewerId: { $ne: null } } // ✅ فقط للمستخدمين المسجلين
 
 
 
4698
  });
4699
+
4700
+ // ✅ للزوار (IP) - من غير unique عشان الزوار الكتير
4701
+ alsoViewedSchema.index({ targetUserId: 1, viewerIp: 1, viewedAt: -1 });
4702
+
4703
+ // ✅ للأقدمية
4704
  alsoViewedSchema.index({ targetUserId: 1, viewedAt: -1 });
4705
 
4706
  const AlsoViewed = mongoose.model('AlsoViewed', alsoViewedSchema);