fixing the fetch limiter
This commit is contained in:
parent
0d081e63ab
commit
f25f6a3f85
|
|
@ -105,6 +105,8 @@ func (s *service) FetchUpcomingEvents(ctx context.Context) error {
|
|||
var count int = 0
|
||||
for _, sportID := range sportIDs {
|
||||
for page != totalPages {
|
||||
time.Sleep(3 * time.Second) //This will restrict the fetching to 1200 requests per hour
|
||||
|
||||
page = page + 1
|
||||
url := fmt.Sprintf("https://api.b365api.com/v1/bet365/upcoming?sport_id=%d&token=%s&page=%d", sportID, s.token, page)
|
||||
log.Printf("📡 Fetching data for event data page %d", page)
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ func (s *ServiceImpl) FetchNonLiveOdds(ctx context.Context) error {
|
|||
}
|
||||
|
||||
for _, event := range eventIDs {
|
||||
time.Sleep(3 * time.Second) //This will restrict the fetching to 1200 requests per hour
|
||||
|
||||
eventID := event.ID
|
||||
prematchURL := "https://api.b365api.com/v3/bet365/prematch?token=" + s.token + "&FI=" + eventID
|
||||
log.Printf("📡 Fetching prematch odds for event ID: %s", eventID)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ import (
|
|||
|
||||
"context"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
// "time"
|
||||
|
||||
eventsvc "github.com/SamuelTariku/FortuneBet-Backend/internal/services/event"
|
||||
oddssvc "github.com/SamuelTariku/FortuneBet-Backend/internal/services/odds"
|
||||
|
|
@ -26,7 +27,6 @@ func StartDataFetchingCrons(eventService eventsvc.Service, oddsService oddssvc.S
|
|||
if err := eventService.FetchUpcomingEvents(context.Background()); err != nil {
|
||||
log.Printf("FetchUpcomingEvents error: %v", err)
|
||||
}
|
||||
time.Sleep(3 * time.Second) //This will restrict the fetching to 1200 requests per hour
|
||||
},
|
||||
},
|
||||
|
||||
|
|
@ -45,8 +45,6 @@ func StartDataFetchingCrons(eventService eventsvc.Service, oddsService oddssvc.S
|
|||
if err := oddsService.FetchNonLiveOdds(context.Background()); err != nil {
|
||||
log.Printf("FetchNonLiveOdds error: %v", err)
|
||||
}
|
||||
time.Sleep(3 * time.Second) //This will restrict the fetching to 1200 requests per hour
|
||||
|
||||
},
|
||||
},
|
||||
// {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user