game lines evaluation for volleyball
This commit is contained in:
parent
4fad17bef7
commit
c78199c163
|
|
@ -214,8 +214,7 @@ var SupportedMarkets = map[int64]bool{
|
|||
int64(CRICKET_TOP_MATCH_BOWLER): false,
|
||||
|
||||
// Volleyball Markets
|
||||
int64(VOLLEYBALL_GAME_LINES): false,
|
||||
|
||||
int64(VOLLEYBALL_GAME_LINES): true,
|
||||
int64(VOLLEYBALL_CORRECT_SET_SCORE): true,
|
||||
int64(VOLLEYBALL_MATCH_TOTAL_ODD_EVEN): true,
|
||||
|
||||
|
|
|
|||
|
|
@ -708,3 +708,12 @@ func evaluateTiedAfterRegulation(outcome domain.BetOutcome, scores []struct{ Hom
|
|||
|
||||
return domain.OUTCOME_STATUS_PENDING, fmt.Errorf("invalid oddname: %s", outcome.OddName)
|
||||
}
|
||||
|
||||
func evaluateVolleyballGamelines(outcome domain.BetOutcome, score struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
||||
switch outcome.OddName {
|
||||
case "Total":
|
||||
return evaluateTotalOverUnder(outcome, score)
|
||||
default:
|
||||
return domain.OUTCOME_STATUS_PENDING, fmt.Errorf("invalid odd name: %s", outcome.OddName)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func (s *Service) FetchAndProcessResults(ctx context.Context) error {
|
|||
continue
|
||||
}
|
||||
|
||||
result, err := s.fetchResult(ctx, outcome.EventID, outcome.OddID, outcome.MarketID, sportID, outcome)
|
||||
result, err := s.FetchResult(ctx, outcome.EventID, outcome.OddID, outcome.MarketID, sportID, outcome)
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to fetch result", "event_id", outcome.EventID, "error", err)
|
||||
continue
|
||||
|
|
@ -167,9 +167,10 @@ func (s *Service) FetchAndProcessResults(ctx context.Context) error {
|
|||
// return s.repo.InsertResult(ctx, result)
|
||||
// }
|
||||
|
||||
func (s *Service) fetchResult(ctx context.Context, eventID, oddID, marketID, sportID int64, outcome domain.BetOutcome) (domain.CreateResult, error) {
|
||||
func (s *Service) FetchResult(ctx context.Context, eventID, oddID, marketID, sportID int64, outcome domain.BetOutcome) (domain.CreateResult, error) {
|
||||
// url := fmt.Sprintf("https://api.b365api.com/v1/bet365/result?token=%s&event_id=%d", s.config.Bet365Token, eventID)
|
||||
url := fmt.Sprintf("https://api.b365api.com/v1/event/view?token=%s&event_id=%d", s.config.Bet365Token, eventID)
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to create request", "event_id", eventID, "error", err)
|
||||
|
|
@ -581,13 +582,25 @@ func (s *Service) evaluateVolleyballOutcome(outcome domain.BetOutcome, res domai
|
|||
|
||||
score := parseSS(res.SS)
|
||||
|
||||
switch outcome.MarketID {
|
||||
// TODO: new Game Lines for volleyball
|
||||
// res.SS example: { 2-3 } is the win count not actuall score of sets
|
||||
// for total score we need every set's score
|
||||
firstSet := parseScore(res.Scores.FirstSet.Home, res.Scores.FirstSet.Away)
|
||||
secondSet := parseScore(res.Scores.SecondSet.Home, res.Scores.SecondSet.Away)
|
||||
thirdSet := parseScore(res.Scores.ThirdSet.Home, res.Scores.ThirdSet.Away)
|
||||
fourthSet := parseScore(res.Scores.FourthSet.Home, res.Scores.FourthSet.Away)
|
||||
fivethSet := parseScore(res.Scores.FivethSet.Home, res.Scores.FivethSet.Away)
|
||||
|
||||
totalScore := struct{ Home, Away int }{Home: 0, Away: 0}
|
||||
totalScore.Home = firstSet.Home + secondSet.Home + thirdSet.Home + fourthSet.Home + fivethSet.Home
|
||||
totalScore.Away = firstSet.Away + secondSet.Away + thirdSet.Away + fourthSet.Away + fivethSet.Away
|
||||
|
||||
switch outcome.MarketID {
|
||||
case int64(domain.VOLLEYBALL_GAME_LINES):
|
||||
return evaluateVolleyballGamelines(outcome, totalScore)
|
||||
case int64(domain.VOLLEYBALL_MATCH_TOTAL_ODD_EVEN):
|
||||
return evaluateGoalsOddEven(outcome, totalScore)
|
||||
case int64(domain.VOLLEYBALL_CORRECT_SET_SCORE):
|
||||
return evaluateCorrectScore(outcome, score)
|
||||
case int64(domain.VOLLEYBALL_MATCH_TOTAL_ODD_EVEN):
|
||||
return evaluateGoalsOddEven(outcome, score)
|
||||
}
|
||||
|
||||
return domain.OUTCOME_STATUS_PENDING, nil
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user