|
|
@ -78,7 +78,7 @@ func (env *Env) BackgroundJobRunner() { |
|
|
|
// Create next run where it's not the past (either from old NextRun or now())
|
|
|
|
timeNow := time.Now() |
|
|
|
startTime := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 10, 0, 0, timeNow.Location()) |
|
|
|
endTime := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 16, 0, 0, timeNow.Location()) |
|
|
|
endTime := startTime.Add(10 * time.Minute) |
|
|
|
|
|
|
|
if timeNow.After(startTime) && timeNow.Before(endTime) { |
|
|
|
err := env.DB.Where(&user.Profile{UserID: jobToDo.UserID}).First(&jobToDo.User.Profile).Error |
|
|
@ -221,7 +221,15 @@ func (env *Env) startBooking(job *Booking, username string, password string, cre |
|
|
|
}() |
|
|
|
} |
|
|
|
|
|
|
|
page = <-pageChan |
|
|
|
// Wait for either page received or timeout
|
|
|
|
select { |
|
|
|
case page = <-pageChan: |
|
|
|
log.Println("Page received.") |
|
|
|
case <-getBookingSlotCtx.Done(): |
|
|
|
log.Println("Context cancelled.") |
|
|
|
browser.MustClose() |
|
|
|
return false |
|
|
|
} |
|
|
|
page.MustActivate() |
|
|
|
|
|
|
|
// Exits if context cancelled
|
|
|
@ -346,6 +354,7 @@ func selectBookingSlot(ctx context.Context, page *rod.Page, timeCode string) *ro |
|
|
|
} |
|
|
|
|
|
|
|
// Start probing
|
|
|
|
reportedTicketDetails := false |
|
|
|
completed := false |
|
|
|
for !completed { |
|
|
|
page.MustWaitLoad() |
|
|
@ -359,6 +368,12 @@ func selectBookingSlot(ctx context.Context, page *rod.Page, timeCode string) *ro |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if !reportedTicketDetails { |
|
|
|
ticketDetails := rowElement.MustText() |
|
|
|
log.Printf("Ticket Details: %s", ticketDetails) |
|
|
|
reportedTicketDetails = true |
|
|
|
} |
|
|
|
|
|
|
|
// Checks for context before clicking
|
|
|
|
select { |
|
|
|
case <-ctx.Done(): |
|
|
|