Feat(booking-job): Handle seat retries
All checks were successful
ktm-booking-bot/ktm-booking-bot/pipeline/head This commit looks good

This commit is contained in:
2022-10-10 00:31:23 +08:00
parent b277e50cd8
commit dcfa34176e

View File

@@ -318,9 +318,8 @@ func (env *Env) startBooking(job *Booking, username string, password string, cre
// // Defer done with debug screenshot
// defer cancelDebugScreenshot()
time.Sleep(600 * time.Second)
time.Sleep(10 * time.Second)
_ = page
browser.MustClose()
return true
}
@@ -435,6 +434,15 @@ func selectBookingSlot(ctx context.Context, page *rod.Page, timeCode string) *ro
time.Sleep(1000 * time.Millisecond)
}
// Repeat if there's no seats -- seats might be released later
if strings.Contains(bodyText, "Not enough seat for onward trip") {
completed = false
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