|
@@ -168,7 +168,7 @@ const updateStraightFixtures = async () => {
|
|
|
}
|
|
}
|
|
|
if (update && update == 'full') {
|
|
if (update && update == 'full') {
|
|
|
const gamesSet = new Set(games.map(game => game.id));
|
|
const gamesSet = new Set(games.map(game => game.id));
|
|
|
- Object.keys(gamesMap).forEach(key => {
|
|
|
|
|
|
|
+ Object.keys(gamesMap)?.forEach(key => {
|
|
|
if (!gamesSet.has(+key)) {
|
|
if (!gamesSet.has(+key)) {
|
|
|
delete gamesMap[key];
|
|
delete gamesMap[key];
|
|
|
}
|
|
}
|
|
@@ -223,8 +223,8 @@ const getStraightOdds = async () => {
|
|
|
const updateStraightOdds = async () => {
|
|
const updateStraightOdds = async () => {
|
|
|
return getStraightOdds()
|
|
return getStraightOdds()
|
|
|
.then(games => {
|
|
.then(games => {
|
|
|
- if (games.length) {
|
|
|
|
|
- const { gamesMap } = GLOBAL_DATA;
|
|
|
|
|
|
|
+ if (games?.length) {
|
|
|
|
|
+ const { gamesMap={} } = GLOBAL_DATA;
|
|
|
games.forEach(game => {
|
|
games.forEach(game => {
|
|
|
const { id, periods, ...rest } = game;
|
|
const { id, periods, ...rest } = game;
|
|
|
const localGame = gamesMap[id];
|
|
const localGame = gamesMap[id];
|
|
@@ -260,7 +260,7 @@ const getSpecialFixtures = async () => {
|
|
|
.then(data => {
|
|
.then(data => {
|
|
|
const { leagues, last } = data;
|
|
const { leagues, last } = data;
|
|
|
if (!last) {
|
|
if (!last) {
|
|
|
- return [];
|
|
|
|
|
|
|
+ return { specials: [], update: 'increment' };
|
|
|
}
|
|
}
|
|
|
GLOBAL_DATA.specialFixturesVersion = last;
|
|
GLOBAL_DATA.specialFixturesVersion = last;
|
|
|
const specials = leagues?.map(league => {
|
|
const specials = leagues?.map(league => {
|
|
@@ -320,7 +320,7 @@ const updateSpecialFixtures = async () => {
|
|
|
.then(data => {
|
|
.then(data => {
|
|
|
const { specials, update } = data;
|
|
const { specials, update } = data;
|
|
|
if (specials?.length) {
|
|
if (specials?.length) {
|
|
|
- const { gamesMap } = GLOBAL_DATA;
|
|
|
|
|
|
|
+ const { gamesMap={} } = GLOBAL_DATA;
|
|
|
const gamesSpecialsMap = {};
|
|
const gamesSpecialsMap = {};
|
|
|
specials.forEach(special => {
|
|
specials.forEach(special => {
|
|
|
const { eventId } = special;
|
|
const { eventId } = special;
|
|
@@ -393,7 +393,7 @@ const updateSpecialsOdds = async () => {
|
|
|
return getSpecialsOdds()
|
|
return getSpecialsOdds()
|
|
|
.then(specials => {
|
|
.then(specials => {
|
|
|
if (specials.length) {
|
|
if (specials.length) {
|
|
|
- const { gamesMap } = GLOBAL_DATA;
|
|
|
|
|
|
|
+ const { gamesMap={} } = GLOBAL_DATA;
|
|
|
const contestants = Object.values(gamesMap)
|
|
const contestants = Object.values(gamesMap)
|
|
|
.filter(game => game.specials)
|
|
.filter(game => game.specials)
|
|
|
.map(game => {
|
|
.map(game => {
|
|
@@ -405,7 +405,7 @@ const updateSpecialsOdds = async () => {
|
|
|
return contestants;
|
|
return contestants;
|
|
|
}).flat(2);
|
|
}).flat(2);
|
|
|
const contestantsMap = new Map(contestants);
|
|
const contestantsMap = new Map(contestants);
|
|
|
- const lines = specials.flatMap(special => special.contestantLines);
|
|
|
|
|
|
|
+ const lines = specials?.flatMap(special => special.contestantLines) ?? [];
|
|
|
lines.forEach(line => {
|
|
lines.forEach(line => {
|
|
|
const { id, handicap, lineId, max, price } = line;
|
|
const { id, handicap, lineId, max, price } = line;
|
|
|
const contestant = contestantsMap.get(id);
|
|
const contestant = contestantsMap.get(id);
|
|
@@ -442,7 +442,7 @@ const updateInRunning = async () => {
|
|
|
if (!games.length) {
|
|
if (!games.length) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- const { gamesMap } = GLOBAL_DATA;
|
|
|
|
|
|
|
+ const { gamesMap={} } = GLOBAL_DATA;
|
|
|
games.forEach(game => {
|
|
games.forEach(game => {
|
|
|
const { id, state, elapsed } = game;
|
|
const { id, state, elapsed } = game;
|
|
|
const localGame = gamesMap[id];
|
|
const localGame = gamesMap[id];
|
|
@@ -643,7 +643,7 @@ const parseGame = (game) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
const getGames = () => {
|
|
const getGames = () => {
|
|
|
- const { filtedGames, gamesMap } = GLOBAL_DATA;
|
|
|
|
|
|
|
+ const { filtedGames, gamesMap={} } = GLOBAL_DATA;
|
|
|
const filtedGamesSet = new Set(filtedGames);
|
|
const filtedGamesSet = new Set(filtedGames);
|
|
|
const nowTime = Date.now();
|
|
const nowTime = Date.now();
|
|
|
const gamesData = {};
|
|
const gamesData = {};
|
|
@@ -687,7 +687,7 @@ const getGames = () => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (actived) {
|
|
if (actived) {
|
|
|
- parseGame(game).forEach(gameInfo => {
|
|
|
|
|
|
|
+ parseGame(game)?.forEach(gameInfo => {
|
|
|
const { marketType, ...rest } = gameInfo;
|
|
const { marketType, ...rest } = gameInfo;
|
|
|
if (!gamesData[marketType]) {
|
|
if (!gamesData[marketType]) {
|
|
|
gamesData[marketType] = [];
|
|
gamesData[marketType] = [];
|
|
@@ -791,7 +791,7 @@ const loadGlobalDataFromCache = async () => {
|
|
|
if (!data) {
|
|
if (!data) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- Object.keys(GLOBAL_DATA).forEach(key => {
|
|
|
|
|
|
|
+ Object.keys(GLOBAL_DATA)?.forEach(key => {
|
|
|
if (key in data) {
|
|
if (key in data) {
|
|
|
GLOBAL_DATA[key] = data[key];
|
|
GLOBAL_DATA[key] = data[key];
|
|
|
}
|
|
}
|