|
|
@@ -18,13 +18,13 @@ const GAMES = {
|
|
|
Relations: {}
|
|
|
};
|
|
|
|
|
|
-const updateGamesList = (({ platform, type, games } = {}) => {
|
|
|
+const updateGamesList = (({ platform, mk, games } = {}) => {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
if (!platform || !games) {
|
|
|
return reject(new Error('PLATFORM_GAMES_INVALID'));
|
|
|
}
|
|
|
|
|
|
- const marketType = type == 0 ? 'early' : 'today';
|
|
|
+ const marketType = mk == 0 ? 'early' : 'today';
|
|
|
|
|
|
let gamesList = games;
|
|
|
|
|
|
@@ -74,11 +74,17 @@ const updateGamesList = (({ platform, type, games } = {}) => {
|
|
|
}
|
|
|
|
|
|
const oldIds = new Set(oldGames.map(item => item.eventId));
|
|
|
+ const relatedGames = Object.values(GAMES.Relations).map(rel => rel[platform] ?? {});
|
|
|
+ const relatedMap = new Map(relatedGames.map(item => [item.eventId, item]));
|
|
|
newGames.forEach(item => {
|
|
|
if (!oldIds.has(item.eventId)) {
|
|
|
oldGames.push(item);
|
|
|
updateCount.add += 1;
|
|
|
}
|
|
|
+ if (relatedMap.has(item.eventId)) {
|
|
|
+ const relatedGame = relatedMap.get(item.eventId);
|
|
|
+ relatedGame.mk = mk;
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
GAMES_LIST[platform][marketType].timestamp = timestamp;
|
|
|
@@ -87,15 +93,15 @@ const updateGamesList = (({ platform, type, games } = {}) => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
-const updateGamesEvents = ({ platform, type, games, outrights }) => {
|
|
|
+const updateGamesEvents = ({ platform, mk, games, outrights }) => {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
if (!platform || (!games && !outrights)) {
|
|
|
return reject(new Error('PLATFORM_GAMES_INVALID'));
|
|
|
}
|
|
|
|
|
|
- const oldGames = Object.values(GAMES.Relations).map(rel => rel[platform] ?? {}).flat();
|
|
|
+ const relatedGames = Object.values(GAMES.Relations).map(rel => rel[platform] ?? {});
|
|
|
|
|
|
- if (!oldGames.length) {
|
|
|
+ if (!relatedGames.length) {
|
|
|
return resolve({ update: 0 });
|
|
|
}
|
|
|
|
|
|
@@ -103,24 +109,24 @@ const updateGamesEvents = ({ platform, type, games, outrights }) => {
|
|
|
update: 0
|
|
|
};
|
|
|
|
|
|
- const oldMap = new Map(oldGames.map(item => [item.eventId, item]));
|
|
|
+ const relatedMap = new Map(relatedGames.map(item => [item.eventId, item]));
|
|
|
|
|
|
games?.forEach(game => {
|
|
|
const { eventId, evtime, events } = game;
|
|
|
- const oldGame = oldMap.get(eventId);
|
|
|
- if (oldGame) {
|
|
|
- oldGame.evtime = evtime;
|
|
|
- oldGame.events = events;
|
|
|
+ const relatedGame = relatedMap.get(eventId);
|
|
|
+ if (relatedGame) {
|
|
|
+ relatedGame.evtime = evtime;
|
|
|
+ relatedGame.events = events;
|
|
|
updateCount.update ++;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
outrights?.forEach(outright => {
|
|
|
const { parentId, sptime, special } = outright;
|
|
|
- const oldGame = oldMap.get(parentId);
|
|
|
- if (oldGame) {
|
|
|
- oldGame.sptime = sptime;
|
|
|
- oldGame.special = special;
|
|
|
+ const relatedGame = relatedMap.get(parentId);
|
|
|
+ if (relatedGame) {
|
|
|
+ relatedGame.sptime = sptime;
|
|
|
+ relatedGame.special = special;
|
|
|
updateCount.update ++;
|
|
|
}
|
|
|
});
|