diff --git a/conf/conf.go b/conf/conf.go index c84adb6..464aca2 100644 --- a/conf/conf.go +++ b/conf/conf.go @@ -387,13 +387,20 @@ func GetNoShowBookings(ctx context.Context) ([]*appdb.Event, error) { WHERE end_time > NOW() AND start_time <= NOW() - INTERVAL '%d MINUTES' AND cancelled_at IS NULL + AND id IN ( + -- Include only those events that have presence monitored. + SELECT DISTINCT event_id + FROM booking.presence_logs + WHERE check_time > NOW() - INTERVAL '%d MINUTES' + ) AND id NOT IN ( + -- Exclude events that have been visited. SELECT DISTINCT event_id FROM booking.presence_logs WHERE occupied = true AND check_time > NOW() - INTERVAL '%d MINUTES' ); - `, cfg.NoShowMins, cfg.NoShowMins)). + `, cfg.NoShowMins, cfg.NoShowMins, cfg.NoShowMins)). BindG(ctx, &bookings) if err != nil { return nil, fmt.Errorf("querying no show bookings: %v", err)