fix(teaching,cme): address late CodeRabbit review on #3614

Merged
BI
1mo ago
+115-13

User description

Follow-up to #3614. This addresses the 6 CodeRabbit threads that were posted after #3614 auto-merged.

Fixes (5)

  1. Dual sign-off reads accept only dual sign-off rows. Rows must carry ratings.kind = "dual_sign_off", applied to the lookup by id and to both lists. Other registrar_assessments rows are never read as assessments or rewritten into one. New test covers this.
  2. Slot times must be ISO 8601 with an offset. startsAt/endsAt use z.string().datetime({ offset: true }).
  3. Booking listings without a role filter in the database. They return the caller's own slots (as supervisor or as trainee), plus open slots when a service is named, instead of scanning every booking.
  4. Part-time EPA minimum is a whole number. It is max(1, ceil(2 × FTE)), never a fraction.
  5. Registrar-only milestones can be edited and deleted. This landed in #3614 itself (PATCH and DELETE on /api/cme/training/[id] fall back to registrar_training_milestones). It is listed here so all 6 threads are accounted for.

No change needed (1)

  • "Sync is never turned on in this test." #3614 restored detection of real clients in shouldSyncRegistrarTable, and the fake client's registrarSync flag opts in. The test runs the sync path and passes.

No sign-off records are created, changed or approved; these are code-level validation changes only.


Summary by cubic

Addresses the six CodeRabbit review threads posted after #3614 auto-merged with five code-level fixes; no sign-off records are created, changed, or approved.

  • Dual sign-off reads accept only rows carrying ratings.kind = "dual_sign_off" (plus legacy rows written before that discriminator existed), so other registrar_assessments rows are never read as assessments or rewritten into one. New tests cover both rejecting foreign rows and preserving pre-marker rows, which an update re-writes with the marker.
  • startsAt/endsAt now require ISO 8601 timestamps with an offset.
  • Role-less booking listings query the database for the caller's own slots (as supervisor and trainee) plus open slots when a service is named, instead of scanning every booking.
  • The part-time EPA minimum is max(1, ceil(2 × FTE)) — a whole number.
  • Registrar-only milestone editing and deletion is listed for completeness; it already landed in #3614.
  • The "sync is never turned on in this test" thread needs no change: #3614 restored real-client detection and the fake client opts into registrarSync, so the test runs the sync path and passes.

CodeAnt-AI Description

Protect dual sign-off records and validate booking schedules

What Changed

  • Dual sign-off views and updates now accept only records created by the dual sign-off flow, leaving unrelated assessment records untouched.
  • Booking times must include a timezone offset, and listings without a role filter show the caller’s own slots plus open slots for the selected service.
  • Part-time rotation EPA targets now round up to a whole number, with a minimum of one.

Impact

✅ Unrelated assessment records stay unchanged
✅ Fewer timezone-ambiguous booking times
✅ Booking lists exclude other users’ slots
✅ Whole-number EPA targets for part-time rotations

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Summary by CodeRabbit

  • Bug Fixes
    • Booking creation now requires start and end times to include a time-zone offset.
    • Part-time rotations now receive an EPA minimum scaled to their FTE, with a minimum of one; full-time rotations and cases without a current rotation retain a minimum of two.
    • Assessment records and booking lists are now filtered and displayed more consistently, including when no role is specified.