fix: double booking instructor err#1178
Conversation
|
Warning Review limit reached
More reviews will be available in 14 minutes and 4 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (10)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Pre-Submission PR Checklist
Description of the change
There was an issue with double-booking instructors, and the eligibility of instructors during assignment. This PR implements a double-booking detection system similar to double-booking rooms.
New database/instructor_conflicts.go: expands an instructor's events/overrides into time slots (getInstructorBookingsInRange) and
detects overlaps against a candidate schedule, honoring per-occurrence instructor overrides, cancellations, and facility timezone.
Refactored rooms.go to share the recurrence-window + overlap + class-name logic (prepareConflictWindow,
buildConflictsFromBookings) between room and instructor checks (DRY). LockAndCheckConflicts now locks and checks room and/or
instructor; conflicts are tagged with ConflictType.
Wired into handleCreateClass, handleUpdateClass (the ticket's "change a class's instructor" path), and handleCreateEvent; returns
HTTP 409 with a type-aware message (instructor vs room). Added instructor-belongs-to-facility validation on the event path.
Frontend: EditClassModal shows an instructor-aware conflict heading; RoomConflict type gains conflict_type.
Tests: new instructor_conflict_test.go covering overlap detection, non-overlap, and the 409-on-instructor-change scenario.
Related issues: https://app.asana.com/1/1201607307149189/project/1209460078641109/task/1214430813078163?focus=true
Related issues: Link to related Asana ticket that this closes.