Skip to content

Commit

Permalink
- Properly add estimatedTimeUtc
Browse files Browse the repository at this point in the history
- Fix null values for Orbit odds (both two and three way)
  • Loading branch information
nigelnindodev committed Oct 19, 2023
1 parent ba4ad60 commit 576db8a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/core/parsers/orbit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ export class OrbitParser extends BaseParser {

private async processRawHtmlMessage(parsedMessage: RawHtmlForProcessingMessage): Promise<void> {
let results2;
let parsedResults: ProcessedTwoWayGameEvent[] | ProcessedThreeWayGameEvent[];
let parsedResults: Array<ProcessedTwoWayGameEvent|null> | Array<ProcessedThreeWayGameEvent|null>;
switch (parsedMessage.betType) {
case BetTypes.TWO_WAY:
results2 = processOrbitGamesHtml(parsedMessage.rawHtml);
if (results2.result === "success") {
parsedResults = results2.value.map(item => {
if (item.oddsArray.length !== 4) {
logger.warn("Skipping two way game event as odds do not total to 4: ", item);
return null;
}
return {
type: BetTypes.TWO_WAY,
betProviderId: `${item.clubA}_${item.clubB}_${item.eventDate}`, // TODO: create id creator on specific betProvider class
Expand All @@ -83,6 +87,10 @@ export class OrbitParser extends BaseParser {
results2 = processOrbitGamesHtml(parsedMessage.rawHtml);
if (results2.result === "success") {
parsedResults = results2.value.map(item => {
if (item.oddsArray.length !== 6) {
logger.warn("Skipping three way game event as odds do not total to 6: ", item);
return null;
}
return {
type: BetTypes.THREE_WAY,
betProviderId: `${item.clubA}_${item.clubB}_${item.eventDate}`,
Expand Down Expand Up @@ -117,6 +125,12 @@ export class OrbitParser extends BaseParser {
logger.info("Successfully fetched games", results2.value);
const getRedisPublisherResult = await RedisSingleton.getPublisher();

// https://stackoverflow.com/a/43130250/22694455
const finalResults: ProcessedTwoWayGameEvent[] | ProcessedThreeWayGameEvent[] = parsedResults.filter(result => {
return result !== null;
}) as ProcessedTwoWayGameEvent[] | ProcessedThreeWayGameEvent[];


if (getRedisPublisherResult.result === "success") {
this.publishProcessedGameEvents(
getRedisPublisherResult.value,
Expand All @@ -125,7 +139,7 @@ export class OrbitParser extends BaseParser {
betProviderName: parsedMessage.betProviderName,
betType: parsedMessage.betType,
gameName: parsedMessage.gameName,
data: parsedResults
data: finalResults
}
);
logger.trace("Published messages to redis on channel: ", getRedisProcessedEventsChannelName(this.betProvider, parsedMessage.gameName, parsedMessage.betType));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const insertThreeWayGameEvent = async (
odds_draw: data.oddsDraw,
game_name: data.gameName,
league: data.league,
estimated_start_time_utc: data.estimatedStartTimeUtc,
meta_data: data.metaData
})
.execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const insertTwoWayGameEvent = async (
odds_b_win: data.oddsBWin,
game_name: data.gameName,
league: data.league,
estimated_start_time_utc: data.estimatedStartTimeUtc,
meta_data: data.metaData
})
.execute();
Expand Down

0 comments on commit 576db8a

Please sign in to comment.