Fix(booking-job): check before completing probe & reduce thread
All checks were successful
ktm-booking-bot/ktm-booking-bot/pipeline/head This commit looks good
All checks were successful
ktm-booking-bot/ktm-booking-bot/pipeline/head This commit looks good
This commit is contained in:
@@ -213,7 +213,7 @@ func (env *Env) startBooking(job *Booking, username string, password string, cre
|
||||
contact := job.Contact
|
||||
reverse := job.BackToSg
|
||||
|
||||
threadCount := 15
|
||||
threadCount := 10
|
||||
for i := 0; i < threadCount; i++ {
|
||||
time.Sleep(time.Millisecond * 100)
|
||||
go func() {
|
||||
@@ -229,6 +229,9 @@ func (env *Env) startBooking(job *Booking, username string, password string, cre
|
||||
currPage = selectBookingSlot(getBookingSlotCtx, currPage, timeCode)
|
||||
log.Println("Booking slot selected.")
|
||||
|
||||
// Make sure page completes loading
|
||||
currPage.MustWaitLoad()
|
||||
|
||||
select {
|
||||
case <-getBookingSlotCtx.Done():
|
||||
return
|
||||
@@ -430,10 +433,16 @@ func selectBookingSlot(ctx context.Context, page *rod.Page, timeCode string) *ro
|
||||
closeModalButton := page.MustElement("#popupModalCloseButton")
|
||||
closeModalButton.Eval(`this.click()`)
|
||||
time.Sleep(1000 * time.Millisecond)
|
||||
}
|
||||
|
||||
styleAttribute := selectButtonElement.MustAttribute("style")
|
||||
if styleAttribute == nil || !strings.Contains(*styleAttribute, "display: none") {
|
||||
completed = false
|
||||
} else {
|
||||
log.Println("Completed probing")
|
||||
completed = true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Checks for context before clicking
|
||||
|
||||
Reference in New Issue
Block a user