Hello, wondering if you store all the existing (ev...
# general
f
Hello, wondering if you store all the existing (even not booked) time slots (e.g., 900 915 | 915 930 | 9:30 - 9:45 | 945 1000) of a plan/event in DB? or you only store the booked slots? which one is the best option in terms of performance. In the former case (when only the details of the plan/events are stored), we need to generate all the corresponding time slots on the fly (when someone wants to see the available times slots for a specific date) by analyzing the plan/event (availability? e.g., Feb 21 - March 21 | Monday-Friday from 900 1700 | Duration of each meeting: 15 minutes), then compare them with booked time slots, and return the list of available/free time slots (for a given date) to the client. In the latter case, I think DB would be much faster but more sparse because you generate all available time slots and store all of them in DB (note that some of the time slots might not be booked at all). Where these time slots for a given date (e.g., Feb 21) are generated, and how they are filtered to find out which ones are booked and which ones are free/available to be booked by a customer/client?
p
maybe @Emrysal knows more
e
We have no intention to store all possible slots, as this can change at any time (imagine the DB update this would require on a 15m to 30m booking length change). We currently do not but we intend to cache busy (user calendar says no) slots on short order, this will start to appear in the coming week(s). The time required to generate the slots available on the fly is very trivial, with only ~250 iterations per day, but most of these will be cached.
f
Thank you for the clarification. May I ask in which file you generate and filter out time slots?
I would like to study that specific piece of code.
e
At the moment we generate our slots in lib/slots.ts but this will change quite soon
f
@Emrysal Thanks. It seems, in the slots.ts you create all the possible slots. Wondering in which file your filter and remove those slots that are already booked?
e
This happens slightly later in useSlots (lib/hooks)