I'm storing peoples availability in slots of 30 minutes, I would like to select multiple sets of 3 consecutive slots of availability which are available, such that I can return 90 minutes of continuous time that is available.
Availability object fields:
- Availability ID
- Person Ref/Lookup
- Start Date/Time
- End Date/Time
- Status (Available/Booked)
Example Data (missing the date to make it easy to read)
01 Keith 09:00 09:30 Available
02 Keith 09:30 10:00 Booked
03 Keith 10:00 10:30 Booked
04 Keith 10:30 11:00 Available
05 Keith 11:00 11:30 Available
06 Keith 11:30 12:00 Available
07 Keith 12:00 12:30 Booked
08 Keith 12:30 13:00 Available
09 Keith 13:00 13:30 Available
10 Keith 13:30 14:00 Available
I want to return these 3 consecutive slots:
04 Keith 10:30 11:00 Available
05 Keith 11:00 11:30 Available
06 Keith 11:30 12:00 Available
And
08 Keith 12:30 13:00 Available
09 Keith 13:00 13:30 Available
10 Keith 13:30 14:00 Available
And not the other rows because they would not total 90 minutes of consecutive time.
How should I approach this SOQL query?