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