Repository navigation
Split large controllers and the teacher calendar into services/components; run frontend tests in CI - #65
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V5ZtSuF2RvbretgLfz7fjJ
…ices LessonsController (621 lines) loaded entities, enforced lesson rules, checked row-level access and sent notifications itself. It is now a thin HTTP layer (150 lines, no DbContext) over: - LessonQueries: read side for teacher, parent and student - LessonService: teacher calendar actions (create, update, delete, complete, no-show, approve/decline new-lesson requests) - LessonRequestService: family requests and the teacher's answer - FamilyMembers: current parent/student and child-ownership checks - TeacherNotifier: teacher notification + email (was private helpers) - ServiceError/ServiceResult: services report NotFound/Forbidden/ Conflict/Invalid; the controller maps them to HTTP Behavior is unchanged; the full backend suite (295 tests) passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V5ZtSuF2RvbretgLfz7fjJ
…rvices MessagesController (572 lines) is now a thin HTTP layer (144 lines, no DbContext) over: - MessageThreads: shared thread mechanics (create, append, detail view, counterpart resolution) - MessageQueries: inbox, thread lists, unread counts, recipients - TeacherMessageService / FamilyMessageService: each side's actions - MessageNotifier: notification and email to teacher / counterpart TeacherNotifier gains SendEmailAsync so messages reuse the same "find teacher, send, log failure" path as lessons instead of a copy. FamilyMembers.IsChildOfAsync now takes a parent id. Behavior is unchanged; the full backend suite (295 tests) passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V5ZtSuF2RvbretgLfz7fjJ
lessons-list.component.ts was 1,224 lines (plus a 626-line template) holding the calendar, five dialogs and all scheduling rules. It is now 657 lines (275-line template): - lesson-scheduling.util.ts: the rules as pure functions — conflicts, availability, what awaits marking, next pending request, future occurrences of a series, all-day event ranges, amount explanation - AddLessonDialogComponent: single lesson or weekly series, with the conflict / outside-availability warnings - CompleteLessonDialogComponent: completing a lesson, incl. the "mark next" batch flow - CalendarEventDialogComponent: personal calendar events - the drag (move) and resize handlers share one helper; request answers share one helper Fix: the personal-event dialog checked for an "endBeforeStart" error that endAfterStartValidator never returns (it returns "dateRange"), so "end time must be after start time" was never shown. Tests: 49 new (40 -> 89) — the util rules, and each dialog's form, validation and service calls. Also verified in a real browser against the running API: batch marking, deep link with ?studentId, auto end time, conflict warning, and the event time error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V5ZtSuF2RvbretgLfz7fjJ
The request form's template checked for an "endBeforeStart" error, but endAfterStartValidator returns "dateRange", so the message never appeared. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V5ZtSuF2RvbretgLfz7fjJ
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Code-structure work on the three largest units, plus frontend tests in CI. Apart from two small UI bug fixes, behavior is unchanged.
LessonsController.csDbContextdirectlyMessagesController.csDbContextdirectlylessons-list.component.ts/.htmlChanges
CI: the
frontend-buildjob now runsnpm test -- --watch=falseafter the build.Backend: lessons (
Talmidon.Api/Services/Lessons/)LessonQueries: the read side for teacher, parent and student. TheLessonDtoprojection was copied 3× and is now defined once.LessonService: the teacher's calendar actions: create, update, delete, complete, no-show, approve/decline a new-lesson request.LessonRequestService: requests from the family, and the teacher's answer to change requests.FamilyMembers: the current parent/student and the parent→child ownership check (row-level access).TeacherNotifier: notification and email to the teacher. These were private helpers in the controller.ServiceError/ServiceResult<T>: services report NotFound / Forbidden / Conflict / Invalid, and the controller maps that to HTTP.Backend: messages (
Talmidon.Api/Services/Messages/)MessageThreads: shared thread mechanics.MessageQueries: the read side.TeacherMessageServiceandFamilyMessageService: each side's actions.MessageNotifier: notifications and email. The teacher email now goes throughTeacherNotifier.SendEmailAsyncinstead of a second copy of the same code.Frontend: teacher calendar (
features/lessons/)lesson-scheduling.util.ts: the scheduling rules as pure functions: conflicts, availability, what is waiting to be marked, the next pending request, future occurrences of a series, all-day event ranges, and the amount explanation.AddLessonDialogComponent,CompleteLessonDialogComponent(including the "mark next" batch flow) andCalendarEventDialogComponent.Bug fixes
endBeforeStarterror, butendAfterStartValidatorreturnsdateRange. As a result, "end time must be after start time" was never shown in either form.Testing
dotnet test, all 295 tests pass after each backend commit. The run covers lesson status transitions, IDOR, tenant isolation, change requests, messaging and notifications.ng test, 89 tests pass, 49 of them new: 32 for the util rules and 17 for the three dialogs (form, validation and service calls, with mocked HTTP).ng buildis clean.?studentId=with the student pre-selected, end time auto-filled from the student's duration, the conflict warning on save, the event time error now visible, saving an event, and no uncaught page errors.Notes for reviewers
System.Security.Cryptography.Pkcs10.0.0 (GHSA-846f-f764-76mx).