Conversation
The check only looked at whether a slot starts inside the exception window. Use the same overlap rule as slot generation: the slot starts before the exception ends and ends after it starts.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughAvailability exception creation now selects slots that overlap the exception window, including slots that start earlier or end at midnight. Allocated matching slots cause a validation error. Unallocated matching slots are marked deleted. ChangesAvailability exception overlap handling
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to The midnight test covers the query behavior it targets, and no actionable overlap defect is established. No merge-blocking risk remains. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change improves overlap handling without showing a new permission bypass or cross-resource access. A concurrent booking can still race with exception creation, and the effect on any legacy overnight slots is not established. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Proposed Changes
start_datetime__time__lt=end_timeandend_datetime__time__gt=start_time. Before, the query wasstart_datetime__timebetweenstart_timeandend_time.The old query only looked at where a slot starts, so:
The new condition is the same half-open overlap
convert_availability_and_exceptions_to_slotsalready uses when it leaves slots out for an exception. Exception creation and slot generation now agree on what counts as a conflict. Slots are single-day (the slot listing filtersstart_datetime__dateandend_datetime__dateto the same day), so comparing times within the date range is enough.Associated Issue
Merge Checklist
test_create_exception_rejects_booked_slot_that_starts_before_it: booked 09:00–10:00, exception 09:30–10:30 → 400 (was 200)test_create_exception_allows_booked_slot_starting_at_its_end: booked 10:30–11:30, exception 09:30–10:30 → 200 and the slot is kept (was 400)test_create_exception_removes_unbooked_slot_that_starts_before_it: empty 09:00–10:00 slot is removed (was kept)developand pass with this change.care.emr.tests.test_schedule_api,test_booking_apiandtest_token_apipass locally./docsruff check/ruff format --checkon the changed files)AI-assisted: I used Claude to help trace the bug and write the tests, then reviewed the change and ran the test suites locally.
@ohcnetwork/care-backend-maintainers @ohcnetwork/care-backend-admins
Summary by CodeRabbit
Update: a booked slot that ends at midnight (e.g. 23:00–00:00) is stored with an end time of 00:00, so the time-of-day overlap check missed it. The filter now also treats a slot whose end time isn't after its start time as running to the end of the day, and
test_create_exception_rejects_booked_slot_ending_at_midnightcovers it (it fails without the change). The schedule and booking suites pass (110 tests).