flyzto 3 сар өмнө
parent
commit
c33a5f802f
1 өөрчлөгдсөн 19 нэмэгдсэн , 14 устгасан
  1. 19 14
      server/models/GamesPs.js

+ 19 - 14
server/models/GamesPs.js

@@ -38,7 +38,6 @@ const BASE_API_URL = IS_DEV ? 'https://api.qboss.vip/api' : 'http://172.17.222.3
 const GAMES = {
   Leagues: {},
   Baselist: {},
-  BaseMatches: [],
   Relations: {},
   Solutions: {},
   UpdateTimestamp: {},
@@ -176,14 +175,14 @@ const syncBaseList = ({ marketType, games }) => {
 /**
  * 清理基准比赛列表
  */
-const cleanupBaseList = () => {
-  const baseList = GAMES.Baselist;
-  const nowTime = Date.now();
-  const expireTime = nowTime - 1000*60*60*3;
-  Object.keys(baseList).forEach(marketType => {
-    baseList[marketType] = baseList[marketType].filter(item => item.timestamp < expireTime);
-  });
-}
+// const cleanupBaseList = () => {
+//   const baseList = GAMES.Baselist;
+//   const nowTime = Date.now();
+//   const expireTime = nowTime - 1000*60*60*3;
+//   Object.keys(baseList).forEach(marketType => {
+//     baseList[marketType] = baseList[marketType].filter(item => item.timestamp < expireTime);
+//   });
+// }
 
 /**
  * 更新比赛列表
@@ -298,6 +297,8 @@ const syncBaseEvents = ({ mk, games, outrights }) => {
         }
       });
 
+      game.matches = matches; // matches 也记录下来
+
       let uptime = evtime ?? 0;
       return { ...gameInfo, matches, uptime };
     });
@@ -306,7 +307,6 @@ const syncBaseEvents = ({ mk, games, outrights }) => {
       // if (mk == 2) {
       //   Logs.out('syncBaseEvents', JSON.stringify({ mk, gamesList }, null, 2));
       // }
-      GAMES.BaseMatches = gamesList;
       submitOdds({ platform: 'ps', mk, games: gamesList });
     }
 
@@ -827,8 +827,9 @@ const getSolution = async (sid) => {
  * 通过比赛 ID 获取中单方案
  */
 const getSolutionsByIds = async (ids) => {
-  const baseMatches = GAMES.BaseMatches;
-  const baseMap = new Map(baseMatches.map(item => [item.eventId, item]));
+  const baseList = Object.values(GAMES.Baselist).flat();
+  Logs.out('baseList', baseList);
+  const baseMap = new Map(baseList.map(item => [item.eventId, item]));
   const result = {};
   ids.forEach(id => {
     const baseGame = baseMap.get(id);
@@ -877,7 +878,7 @@ const solutionsCleanup = () => {
  * 定时清理盘口信息
  */
 setInterval(() => {
-  cleanupBaseList();
+  // cleanupBaseList();
   solutionsCleanup();
   gamesRelationCleanup();
 }, 1000*30);
@@ -1034,7 +1035,11 @@ const saveGamesToCache = () => {
  */
 const loadGamesFromCache = () => {
   const gamesCacheData = Cache.getData(GamesCacheFile, true);
-  Object.assign(GAMES, gamesCacheData);
+  Object.keys(GAMES).forEach(key => {
+    if (gamesCacheData[key]) {
+      GAMES[key] = gamesCacheData[key];
+    }
+  });
   Logs.out('Games cache loaded successfully');
 }