Sitemap

Checking for open slots in

Apply advanced filtering via options inside relations

--

In my previous blog post about meeting rooms, I shared some code snippets that output a list of available time slots. Each time slot is represented by a list with two elements: the start time and the end time of the room’s availability. For example, if a room is booked on Monday, November 4th between 9:00 AM and 10:00 AM and again between 3:00 PM and 4:00 PM, the open time slots would be: midnight to 9:00 AM, 10:00 AM to 3:00 PM, and 4:00 PM to midnight.

This is the code snippet that generates the list of open slots you see here:

[DB Reservations].Filter(room.Contains(thisRow.room)).Sort().WithName(root,

ListCombine(
root.startDate, root.endDate).Sort().WithName(theDates,

Sequence(2,theDates.Count()).ForEach(CurrentValue.WithName(nbr,
SwitchIf(
theDates.Nth(nbr) - theDates.Nth(nbr - 1) > 0,
List(theDates.Nth(nbr - 1), theDates.Nth(nbr)))
))).WithName(pairs,

Sequence(1,pairs.ListCombine().Count()).ForEach(CurrentValue.WithName(nbr,

SwitchIf(
[DB Reservations].Filter(
startDate.Contains(pairs.Nth(nbr).First()) OR
endDate.Contains(pairs.Nth(nbr ).Last())…

--

--

Christiaan Huizer
Christiaan Huizer

Written by Christiaan Huizer

I write every week about how to Coda . You find blogs for beginners and experienced makers. Until 7 days after publication you read my blog for free. Welcome!

No responses yet