Преглед изворни кода

保持不变的方案更新

flyzto пре 3 месеци
родитељ
комит
89e24bb704
1 измењених фајлова са 13 додато и 10 уклоњено
  1. 13 10
      server/models/GamesPs.js

+ 13 - 10
server/models/GamesPs.js

@@ -667,7 +667,7 @@ const updateSolutions = (solutions) => {
 
   if (solutions?.length) {
     const solutionsHistory = GAMES.Solutions;
-    const updateIds = { add: [], update: [] }
+    const updateIds = { add: [], update: [], retain: [] }
     solutions.forEach(item => {
       const { sid, cpr, sol: { win_average } } = item;
 
@@ -685,18 +685,21 @@ const updateSolutions = (solutions) => {
       }
 
       const { timestamp } = item;
-      solutionsHistory[sid].timestamp = timestamp;
-
+      historySolution.timestamp = timestamp;
+      updateIds.retain.push(sid);
     });
 
-    if (updateIds.add.length || updateIds.update.length) {
-      const solutionUpdate = {};
-      Object.keys(updateIds).forEach(key => {
+    const solutionUpdate = {};
+    Object.keys(updateIds).forEach(key => {
+      if (key == 'retain') {
+        solutionUpdate[key] = updateIds[key];
+      }
+      else {
         solutionUpdate[key] = updateIds[key].map(sid => solutionsHistory[sid]);
-      });
-      syncSolutions(solutionUpdate);
-      // Logs.outDev('solutions history update', solutionUpdate);
-    }
+      }
+    });
+    syncSolutions(solutionUpdate);
+
   }
 }