[CAL-3458] Slot shows as available even if event limit exceeds
Found a bug? Please fill out the sections below. 👍
Issue Summary
I have limits set for my specific event. One of my mentees tried to book a session. From the message, it seems the limit exceeded. In this case, I think the slot should be shown as unavailable
Steps to Reproduce
My customers reported this issue on events that I have set limit upon
Any other relevant information. For example, why do you consider this a bug and what did you expect to happen instead?
Actual Results
- Date is shown as available, but when customer tries to book, error is thrown
Expected Results
- The date shouldn't be available at all
Technical details
- Customers reported this across browsers like Chrome and Firefox
Evidence
- Check screenshot
From SyncLinear.com | CAL-3458
Hello again, @ahmedsadman! It's great to see you reaching out with your insights. Let's take a look at what's happening here.
Thank you for the detailed description of the issue. It seems like you're encountering a problem where event slots are still displayed as available even after reaching the booking limit. This is indeed a confusing behavior and can lead to a poor user experience.
I found a similar issue that was closed in the past: [CAL-1608] When certain limits in place - "Could not book a meeting" error. However, it seems like the problem you're facing is slightly different.
To resolve this issue, we can modify the logic within the getSchedule function to consider the booking limits defined for each event type. Once the limit is reached for a particular day, no more slots should be shown as available for that day. Here's a high-level approach to implement the solution:
-
Define Booking Limits: Ensure that each event type has a defined booking limit. This can be a global limit or vary by day.
-
Track Bookings: Keep track of the number of accepted bookings for each event type and day. This requires querying the database for bookings that are accepted (
status: "ACCEPTED") and grouping them by event type and day. -
Modify
getScheduleLogic: Before returning available slots, thegetSchedulefunction should check if the booking limit for the event type and day has been reached. If the limit is reached, it should exclude those slots from the results. -
Update Tests: Ensure that your test cases in
getSchedule.test.tsreflect this new logic. You might need to add new tests that specifically test for scenarios where the booking limit is reached.
Here's a simplified example of how you might adjust the getSchedule function to consider booking limits:
async function getSchedule(input: GetScheduleInput): Promise<ScheduleResult> {
// Existing logic to calculate available slots...
// New logic to filter out slots based on booking limits
const bookings = await getBookingsForEventTypes(input.eventTypeId);
const bookingCountsByDay = countBookingsByDay(bookings);
const filteredSlots = filterSlotsByBookingLimit(availableSlots, bookingCountsByDay, bookingLimitPerDay);
return filteredSlots;
}
function countBookingsByDay(bookings: Booking[]): Record<string, number> {
// Implement logic to count bookings by day
}
function filterSlotsByBookingLimit(slots: Slot[], bookingCountsByDay: Record<string, number>, limit: number): Slot[] {
// Implement logic to filter out slots based on booking limits
}
Please note that this example outlines the general approach but doesn't cover all details, such as the structure of your data models or the exact implementation of helper functions like getBookingsForEventTypes, countBookingsByDay, and filterSlotsByBookingLimit. You'll need to adapt this approach to fit the specific architecture and data models of your application.
I hope this helps! If you have any further questions or need more clarification, feel free to ask.
Sources
- [CAL-1608] When certain limits in place - "Could not book a meeting" error
- apps/web/test/lib/getSchedule.test.ts
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.