Optimize booking workflow and slot reservation pipeline#8
Optimize booking workflow and slot reservation pipeline#8ShashankFC wants to merge 1 commit intomainfrom
Conversation
- Enhance quick availability check logic - Improve slot reservation interval timing - Refine timezone-based slot lookup algorithm - Update week view display configuration - Optimize slot reservation ID handling
Entelligence AI Vulnerability ScannerStatus: No security vulnerabilities found Your code passed our comprehensive security analysis. Analyzed 3 files in total |
Review Summary❌ Rejected Comments (2)
🏷️ Draft Comments (3)
|
🔬 Multi-Approach Review SummaryThis PR was reviewed by 2 different approaches for comparison:
Total: 2 review comments Each comment is labeled with its source approach. This allows you to compare different AI review strategies. 🔒 Security Scan: Run once and shared across all approaches for efficiency. WalkthroughThis PR addresses critical bugs in the booking slot reservation and availability checking logic. The changes fix a mathematical error in the reservation refresh interval calculation that could result in negative intervals, ensure proper type handling for slot reservation IDs, and correct inverted logic in timeslot availability checks. Additionally, it extends the date range lookup window to handle timezone edge cases and adjusts the desktop week view configuration to display 6 days instead of 7 for improved UI layout. Changes
Sequence DiagramThis diagram shows the interactions between components: sequenceDiagram
participant Client
participant BookingComponent
participant ReservationAPI
Client->>BookingComponent: Initiate booking flow
Note over BookingComponent: Prepare reservation data<br/>with eventTypeId, duration,<br/>timeslots, slotReservationId
BookingComponent->>BookingComponent: Set slotReservationId<br/>(value or undefined)
BookingComponent->>ReservationAPI: handleReserveSlot()<br/>(initial reservation)
ReservationAPI-->>BookingComponent: Reservation created
Note over BookingComponent: Start interval timer<br/>((MINUTES_TO_BOOK - 2000) * 60 * 1000)
activate BookingComponent
loop Periodic Refresh (every ~MINUTES_TO_BOOK - 2s)
BookingComponent->>ReservationAPI: handleReserveSlot()<br/>(refresh reservation)
ReservationAPI-->>BookingComponent: Reservation extended
end
deactivate BookingComponent
alt Booking completed or cancelled
BookingComponent->>ReservationAPI: handleRemoveSlot()<br/>(cleanup)
ReservationAPI-->>BookingComponent: Slot released
BookingComponent->>BookingComponent: Clear interval timer
end
🔒 Security Analysis
Note for WindsurfPlease change the default marketplace provider to the following in the windsurf settings:Marketplace Extension Gallery Service URL: https://marketplace.visualstudio.com/_apis/public/gallery Marketplace Gallery Item URL: https://marketplace.visualstudio.com/items Entelligence.ai can learn from your feedback. Simply add 👍 / 👎 emojis to teach it your preferences. More shortcuts belowEmoji Descriptions:
Interact with the Bot:
Also you can trigger various commands with the bot by doing The current supported commands are
More commands to be added soon. |
| // We don't want to look up for a slot over all the dates in the schedule data unnecessarily for performance reasons | ||
| const dateBefore = dayjs(dateInGMT).subtract(1, "day").format("YYYY-MM-DD"); | ||
| const dateAfter = dayjs(dateInGMT).add(1, "day").format("YYYY-MM-DD"); | ||
| const dateAfter = dayjs(dateInGMT).add(2, "day").format("YYYY-MM-DD"); |
There was a problem hiding this comment.
correctness: 🟢 [Standard Reviewer] dateAfter is set to two days after dateInGMT, causing the slot lookup to miss the correct adjacent day and potentially return false negatives for valid slots.
🤖 AI Agent Prompt for Cursor/Windsurf
📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue
In packages/features/bookings/Booker/utils/isTimeslotAvailable.ts, line 47, the calculation for `dateAfter` incorrectly adds 2 days instead of 1. This causes the slot lookup to miss valid slots that fall on the next day, resulting in false negatives. Change line 47 to add only 1 day: `const dateAfter = dayjs(dateInGMT).add(1, "day").format("YYYY-MM-DD");`.
📝 Committable Code Suggestion
‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.
| const dateAfter = dayjs(dateInGMT).add(2, "day").format("YYYY-MM-DD"); | |
| const dateAfter = dayjs(dateInGMT).add(1, "day").format("YYYY-MM-DD"); |
| quickAvailabilityChecks && | ||
| quickAvailabilityChecks.some( | ||
| (slot) => slot.utcStartIso === slotToCheckInIso && slot.status !== "available" | ||
| (slot) => slot.utcStartIso === slotToCheckInIso && slot.status === "available" |
There was a problem hiding this comment.
correctness: 🟢 [Standard Reviewer] isUnavailableAsPerQuickCheck returns true if slot is available, causing isTimeSlotAvailable to return false for available slots (logic inversion).
🤖 AI Agent Prompt for Cursor/Windsurf
📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue
In packages/features/bookings/Booker/utils/isTimeslotAvailable.ts, line 84, the logic for `isUnavailableAsPerQuickCheck` is inverted: it returns true if the slot is available, causing the function to return false for available slots. Change the condition to check for slots that are NOT available: `(slot) => slot.utcStartIso === slotToCheckInIso && slot.status !== "available"`.
📝 Committable Code Suggestion
‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.
| (slot) => slot.utcStartIso === slotToCheckInIso && slot.status === "available" | |
| (slot) => slot.utcStartIso === slotToCheckInIso && slot.status !== "available" |
This PR optimizes the booking workflow with improved slot availability checks and refined reservation timing mechanisms for better user experience.
EntelligenceAI PR Summary
This PR fixes critical bugs in booking slot reservation and availability logic, along with a UI configuration adjustment.
slotReservationIdtoundefinedfor proper type handling