Hi everyone,
I’d love to get your input and expertise on an issue I’m facing.
I’m working on an equipment rental app, and I want to add a feature that displays only the available items when a user creates a new reservation. Here’s the database structure I’ve set up (simplified for this post):
- Equipment
- EquipmentItem
- Reservation
- Participant
- ReservedEquipment
- Equipment
- EquipmentItem
- Reservation
- Participant
- ReservationDateRange
Reservation Process
When creating a reservation, the user (renter) assigns equipment to a participant. Later in the process, they link a specific item to the participant.
The challenge: I want to display only the equipment items that are available on the selected reservation dates.
My Current Workflow
Here’s the workflow I’ve implemented. It works but might become slow with larger datasets:
- Step 1: (Create a variable using “Make changes to a list”)
- Search for
ReservedEquipment
- Constraint:
ReservationDateRange
overlaps with input startDate <- range -> input endDate
- Step 2:
- Filter the results from Step 1 using an advanced constraint:
Search for EquipmentItems
(constraint: equipment = this ReservedEquipment’s Equipment
): count <=
Result of Step 1:filtered
(constraint: equipment = this ReservedEquipment’s Equipment
): count
Explanation
In short, I retrieve a list of all equipment and compare it to the reserved equipment list for the same model in the advanced filter. Then, as a result, I get all the unavailable equipment and remove those items from the list displayed to the user (renter).
While this method works, I’m concerned about its performance with a larger dataset, especially because it relies on advanced filters and nested searches.
Has anyone encountered a similar use case? Do you have suggestions for a more efficient approach? I’d like to avoid nested searches, particularly in the “Advanced” filter.
Thanks in advance for your help!
I’ve built some pretty comprehensive booking systems and I’d recommend two changes to what you’re currently doing.
First, I’d utilise start and finish dates for a reservation instead of a date range. Makes it a lot easier to utilise things like +minutes / days, etc down the line.
Second, I’d create a ‘Reserved’ field within the equipment itself so that when an item is booked you essentially log the Reservation against that piece of equipment. Do a search for can become challenging quickly with booking systems so you need to narrow down / filter searches before they even happen with how your system is structured.
One of my products allows customers to manage relatively complex booking processes for north of 250 individual items using this approach, and doesn’t have a single ‘Do a search for’ function.
Once you’ve added the ‘Reserved’ field to the equipment, when a user is viewing a certain piece of equipment, once a date or date range has been selected you can use a conditional expression and advanced filter that says when this equipments ‘Reserved’:count > 0 (ie when this equipments reserved items have a date that overlaps with the selected date / range), this item is not visible.
Apologies if that isn’t the most comprehensive explanation. My best advice is to utilise your database structure and the product itself to encourage users to filter down the search query as much as possible before having the system actually perform a search. It’ll seriously improve performance and keep the process simpler for your users.
2 Likes
Hey mate,
Thanks again for taking the time to provide such detailed feedback! I really appreciate your insights and experience.
I have a few questions about your approach.
I’ve seen quite a few posts on Twitter discussing the use of lists in Bubble, suggesting that it’s best to avoid them or at least keep them at a manageable size. In my case, the reservation list could grow significantly (100+ entries).
Each piece of Equipment
in my app has multiple EquipmentItem
(different sizes available, and several items per size). As mentioned, assigning a specific EquipmentItem
happens later in the process, closer to the handover date. I’d need to store this reservation list in my Equipment
table.
The user must be able to view all available equipment and filter it afterward. However, I’m concerned that storing a Reservation
list directly in my Equipment
table could make the process heavier.
To optimize performance, I’ve decided to store the lists of EquipmentItem
and ReservedEquipment
in variables and only filter them when loading the data. The initial load seems a bit slow, but subsequent loads are much faster since the lists are already cached.
That being said, your approach has me questioning my own. Have you experienced any noticeable slowdowns with such large lists attached to your items?