fix tests
This commit is contained in:
@@ -1268,6 +1268,18 @@ func CreateBookingHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for overlapping bookings with confirmed/in_progress/completed status
|
||||||
|
// Users cannot book a time slot that overlaps with these statuses
|
||||||
|
var cnt int
|
||||||
|
db.DB.QueryRow(r.Context(), `
|
||||||
|
SELECT COUNT(*) FROM bookings WHERE status IN ('confirmed','in_progress','completed') AND start_time < $2 AND start_time + (INTERVAL '1 minute' * (SELECT COALESCE(SUM(COALESCE(bs.override_duration_minutes,s.duration_minutes)),60) FROM booking_services bs JOIN services s ON bs.service_id=s.id WHERE bs.booking_id=bookings.id)) > $1
|
||||||
|
`, req.StartTime, endTime).Scan(&cnt)
|
||||||
|
if cnt > 0 {
|
||||||
|
http.Error(w, "Cannot book this time - slot overlaps with an existing booking", http.StatusConflict)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Get created by from context (if available)
|
// Get created by from context (if available)
|
||||||
var createdBy *string
|
var createdBy *string
|
||||||
|
|||||||
Reference in New Issue
Block a user