|
@@ -677,9 +677,9 @@ const fetchGamesRelation = async (mk='') => {
|
|
|
hg_event_id, hg_league_id,
|
|
hg_event_id, hg_league_id,
|
|
|
hg_team_home_name,
|
|
hg_team_home_name,
|
|
|
hg_team_away_name,
|
|
hg_team_away_name,
|
|
|
- im_event_id, im_league_id,
|
|
|
|
|
- im_team_home_name,
|
|
|
|
|
- im_team_away_name,
|
|
|
|
|
|
|
+ // im_event_id, im_league_id,
|
|
|
|
|
+ // im_team_home_name,
|
|
|
|
|
+ // im_team_away_name,
|
|
|
updated,
|
|
updated,
|
|
|
timestamp,
|
|
timestamp,
|
|
|
} = item;
|
|
} = item;
|
|
@@ -708,14 +708,14 @@ const fetchGamesRelation = async (mk='') => {
|
|
|
teamAwayName: hg_team_away_name,
|
|
teamAwayName: hg_team_away_name,
|
|
|
timestamp
|
|
timestamp
|
|
|
} : null,
|
|
} : null,
|
|
|
- im: im_event_id ? {
|
|
|
|
|
- eventId: +im_event_id,
|
|
|
|
|
- leagueId: +im_league_id,
|
|
|
|
|
- leagueName: league_name,
|
|
|
|
|
- teamHomeName: im_team_home_name,
|
|
|
|
|
- teamAwayName: im_team_away_name,
|
|
|
|
|
- timestamp
|
|
|
|
|
- } : null
|
|
|
|
|
|
|
+ // im: im_event_id ? {
|
|
|
|
|
+ // eventId: +im_event_id,
|
|
|
|
|
+ // leagueId: +im_league_id,
|
|
|
|
|
+ // leagueName: league_name,
|
|
|
|
|
+ // teamHomeName: im_team_home_name,
|
|
|
|
|
+ // teamAwayName: im_team_away_name,
|
|
|
|
|
+ // timestamp
|
|
|
|
|
+ // } : null
|
|
|
};
|
|
};
|
|
|
const rels = [];
|
|
const rels = [];
|
|
|
rels.push({ id: ps_event_id, mk, rel, timestamp, updated });
|
|
rels.push({ id: ps_event_id, mk, rel, timestamp, updated });
|
|
@@ -785,7 +785,14 @@ const getPCData = (id) => {
|
|
|
* @property {boolean} listPC
|
|
* @property {boolean} listPC
|
|
|
* @returns {object[]}
|
|
* @returns {object[]}
|
|
|
*/
|
|
*/
|
|
|
-const getGamesRelation = ({ mk=-1, ids, listEvents=false, listPC=false, listOdds=false } = {}) => {
|
|
|
|
|
|
|
+const getGamesRelation = ({
|
|
|
|
|
+ mk=-1, ids,
|
|
|
|
|
+ listEvents=false,
|
|
|
|
|
+ listPC=false,
|
|
|
|
|
+ listOdds=false,
|
|
|
|
|
+ hideBase=false,
|
|
|
|
|
+ hideHalf=false,
|
|
|
|
|
+} = {}) => {
|
|
|
|
|
|
|
|
let relations;
|
|
let relations;
|
|
|
if (ids?.length) {
|
|
if (ids?.length) {
|
|
@@ -795,9 +802,20 @@ const getGamesRelation = ({ mk=-1, ids, listEvents=false, listPC=false, listOdds
|
|
|
relations = Object.values(GAMES.Relations);
|
|
relations = Object.values(GAMES.Relations);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- relations = relations.filter(item => !!item && (mk == -1 || item.mk == mk)).sort((a, b) => a.timestamp - b.timestamp);
|
|
|
|
|
|
|
+ relations = relations.filter(item => {
|
|
|
|
|
+ if (!item) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (hideHalf && item.id < 0) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (mk >= 0 && item.mk != mk) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }).sort((a, b) => a.timestamp - b.timestamp);
|
|
|
|
|
|
|
|
- if (listEvents && !listPC) {
|
|
|
|
|
|
|
+ if (listEvents && !listPC && !hideBase && !hideHalf) {
|
|
|
return relations;
|
|
return relations;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -808,18 +826,19 @@ const getGamesRelation = ({ mk=-1, ids, listEvents=false, listPC=false, listOdds
|
|
|
if (listPC) {
|
|
if (listPC) {
|
|
|
tempRel.pc = getPCData(id);
|
|
tempRel.pc = getPCData(id);
|
|
|
}
|
|
}
|
|
|
- if (!listEvents) {
|
|
|
|
|
- Object.keys(tempRel).forEach(platform => {
|
|
|
|
|
- const { events, evtime, special, sptime, ...gameInfo } = tempRel[platform] ?? {};
|
|
|
|
|
- if (listOdds) {
|
|
|
|
|
- const { odds, evExpire, spExpire } = extractOdds({ platform, evtime, events, sptime, special });
|
|
|
|
|
- tempRel[platform] = { ...gameInfo, odds, evExpire, spExpire };
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- tempRel[platform] = gameInfo;
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ if (hideBase) {
|
|
|
|
|
+ delete tempRel.ps;
|
|
|
}
|
|
}
|
|
|
|
|
+ Object.keys(tempRel).forEach(platform => {
|
|
|
|
|
+ const { events, evtime, special, sptime, ...gameInfo } = tempRel[platform] ?? {};
|
|
|
|
|
+ if (!listEvents) {
|
|
|
|
|
+ tempRel[platform] = gameInfo;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (listOdds) {
|
|
|
|
|
+ const { odds, evExpire, spExpire } = extractOdds({ platform, evtime, events, sptime, special });
|
|
|
|
|
+ tempRel[platform] = { ...tempRel[platform], odds, evExpire, spExpire };
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
return { ...relationInfo, rel: tempRel };
|
|
return { ...relationInfo, rel: tempRel };
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|