Hey Bubblers, I’m currently in the process of building a hotel/property marketplace like Airbnb.
I’m a little stuck when it comes to excluding properties on a search results page if they’ve already been booked on a date that a user is searching for.
Let me explain in more detail.
On my overarching ‘property’ data type, I have a data field that stores a list of all the dates that a property is booked for. This field type is set to be a list of date ranges and is referred to as the ‘booked dates’.
I also have another data type called a ‘booking’. Whenever a booking is created, I link this back to an original property, and also store a single date range in which the booking will take place.
Right now, I’m in the process of building a search results page to display a list of relevant properties.
On this page, a user will input their desired check-in date and check-out date that they would like to stay for.
From here, I want to display a list of relevant properties that have not yet been booked on any of their selected dates.
For example, let’s say a property has already been booked for the dates of 12th Sept - 15th Sept, as well the 21st Sept - 22nd Sept. Both of these date ranges would be listed in my ‘booked dates’ data field under the property data type.
If the user was to search for a property where the check-in date is the 11th Sept 2022 - 13th Sept 2022, the property with the booked dates above should not be displayed.
I’ve attempted to add an advanced filter on my repeating group data source. This filter leverages the ‘overlaps’ expression, but this doesn’t seem to do the trick. I’m under the impression that an overlap would only occur if a user is searching for an exact date range that already exists in the ‘booked dates’ list of date ranges.
E.g. if a user searches for 12th Sept - 15th Sept and the property has been booked on these exact days; this would be an overlap.
Note: Within the filter, you’ll see I’m creating a range between two URL parameters. These are parameters I’m sending through which are the check-in date, as well as the check-out date.
I’m a little stuck as to what my options are here. I’d be so thankful if anyone had any suggestions I could try.