Skill: Search Available Slots
Overview
This skill implements the logic for finding available booking slots across all fields. It uses a 30-Minute Grid strategy to balance user flexibility with field utilization.
Search Strategy: 30-Minute Grid
Instead of searching on the hour (e.g., 10:00, 11:00) or using complex gap-filling logic, the system standardizes on a 30-minute interval grid.
Intervals: 00, 30 Start Times: 08:00, 08:30, 09:00, 09:30, ... 22:30, 23:00.
Why this strategy?
- •Flexibility: Catches slots that start on the half-hour (e.g., 14:30) which hourly searches miss.
- •Simplicity: Avoids complex logic to check "immediately after previous booking".
- •Predictability: Users are accustomed to 30-minute increments.
Algorithm
- •
Define Search Window:
- •Start:
Math.max(OpenTime, CurrentTime + Buffer)(Rounded up to next 30 min) - •End:
CloseTime(24:00) - •Step:
30 minutes
- •Start:
- •
Conflict Check:
- •For each candidate start time
S: - •Calculate
E = S + Duration - •Check if
S < Booking.EndANDE > Booking.Startfor any existing booking. - •If
false, the slot is Available.
- •For each candidate start time
Usage in Code (searchService.ts)
typescript
const SEARCH_STEP_MIN = 30; // Grid interval
// Loop through the day in 30-minute steps
for (let start = startMin; start + duration <= endMin; start += SEARCH_STEP_MIN) {
if (isSlotFree(start)) {
slots.push({ start, end: start + duration });
}
}
Best Practices
- •Do not revert to Hourly: This will miss revenue opportunities (e.g., 1.5hr slot starting at 13:30).
- •Frontend Display: Show results in a Carousel or List, sorted by time.