flyzto 4 hónapja
szülő
commit
6d3af53eab
1 módosított fájl, 16 hozzáadás és 6 törlés
  1. 16 6
      server/models/GamesPs.js

+ 16 - 6
server/models/GamesPs.js

@@ -167,14 +167,8 @@ const updateGamesList = (({ platform, mk, games } = {}) => {
       return reject(new Error('PLATFORM_GAMES_INVALID'));
     }
 
-    const marketType = getMarketType(mk);
-
     syncGamesList({ platform, mk, games });
 
-    if (platform == 'ps') {
-      syncBaseList({ marketType, games });
-    }
-
     resolve();
   });
 });
@@ -482,6 +476,22 @@ const updateGamesRelation = () => {
   fetchGamesRelation()
   .then(gamesRelation => {
 
+    const baseList = {};
+    gamesRelation.map(item => {
+      const baseGame = item.rel?.['ps'] ?? {};
+      return { ...baseGame };
+    }).forEach(item => {
+      const marketType = getMarketType(item.mk);
+      if (!baseList[marketType]) {
+        baseList[marketType] = [];
+      }
+      baseList[marketType].push(item);
+    });
+
+    Object.keys(baseList).forEach(marketType => {
+      syncBaseList({ marketType, games: baseList[marketType] });
+    });
+
     const updateCount = {
       add: 0,
       update: 0,