Skip to content

fix: double booking instructor err#1178

Open
CK-7vn wants to merge 1 commit into
mainfrom
CK-7vn/instructor-conflict
Open

fix: double booking instructor err#1178
CK-7vn wants to merge 1 commit into
mainfrom
CK-7vn/instructor-conflict

Conversation

@CK-7vn

@CK-7vn CK-7vn commented Jun 16, 2026

Copy link
Copy Markdown
Member

Pre-Submission PR Checklist

  • No debug/console/fmt.Println statements
  • Unnecessary development comments removed
  • All acceptance criteria verified
  • Functions according to ticket spexifications
  • Tested manually where applicable
  • Branch rebased with latest main
  • No business logic exists within the database layer

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.

@CK-7vn CK-7vn requested a review from a team as a code owner June 16, 2026 22:37
@CK-7vn CK-7vn requested review from corypride and removed request for a team June 16, 2026 22:37
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@CK-7vn, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 523f3ea0-8dcb-4330-8d60-b8ecf83e0612

📥 Commits

Reviewing files that changed from the base of the PR and between 76550ac and 81c373e.

📒 Files selected for processing (10)
  • backend/src/database/instructor_conflicts.go
  • backend/src/database/program_classes.go
  • backend/src/database/rooms.go
  • backend/src/handlers/class_events.go
  • backend/src/handlers/classes_handler.go
  • backend/src/handlers/server.go
  • backend/src/models/facilities.go
  • backend/tests/integration/instructor_conflict_test.go
  • frontend/src/pages/class-detail/EditClassModal.tsx
  • frontend/src/types/facility.ts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant