Repository navigation
Seminar duplicate-lesson guard (from PR #191, real migration timestamp) - #192
Merged
Merged
Conversation
Same texts as PR #191's migration, filename/class timestamped with actual Date.now() instead of a rounded placeholder. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WER1oSuN8tCQTNRU73Mi89
Adds the duplicate-lesson-punch handling in processSeminarAttendanceCall (ask 1=add another, 2=delete previous, with cascade cleanup of now-unused ReportGroupSession/ReportGroup rows) plus its test coverage, alongside the previously added texts migration with a real timestamp. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WER1oSuN8tCQTNRU73Mi89
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved review comments; migration insert and rollback logic are complete.
Pull request overview
Adds a TypeORM migration for seminar duplicate-lesson IVR texts using a real timestamp.
Changes:
- Seeds two texts for
user_id0. - Removes both texts on rollback.
- Uses chronological timestamp
1789587905258.
File summaries
| File | Description |
|---|---|
server/src/migrations/1789587905258-UpdateYemotTextsSeminarDuplicateLesson.ts |
Seeds and removes duplicate-lesson texts. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Strip the ReportGroup/ReportGroupSession cascade cleanup on "delete previous": it never checked Grade rows also FK-referencing ReportGroupSession (ON DELETE NO ACTION), so it could throw and abort the whole transaction. Orphaned group/session rows are harmless, so just stop touching them and only delete the duplicate AttReport rows. Also move the duplicate check right after the lesson is resolved (before the roster fetch), so the caller is asked as soon as possible, while the actual delete now happens atomically inside saveSeminarAttendance's transaction, right before the fresh rows are inserted. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WER1oSuN8tCQTNRU73Mi89
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.
Problem
Client report: girls validated the same lesson multiple times. The seminar attendance IVR flow had no duplicate check on the lesson punch.
Fix
In
processSeminarAttendanceCall, once alessonReferenceIdis resolved from the schedule,askDuplicateLessonChoiceimmediately checksAttReportfor an existing row for the same user + klass + teacher + lesson + today (Israel date), and if found asks the caller right away:The choice is only remembered at that point. The actual delete of the prior
AttReportrows happens later, insidesaveSeminarAttendance's transaction, immediately before the fresh rows are inserted — so the old report isn't touched until the new one is ready to replace it in the same atomic operation, and the "previous report deleted" confirmation is sent only once that's actually done.No existing row → flow unchanged. No schedule match (no
lessonReferenceId) → flow unchanged.Dropped from PR #191: the cascade cleanup that also deleted now-unreferenced
ReportGroupSession/ReportGrouprows. It only checkedAttReportbefore deleting a session, butGrade.reportGroupSessionIdalso FKs toreport_group_sessionswithON DELETE NO ACTION— if anyGraderow referenced that session, the delete would throw and abort the whole transaction mid-call. Orphaned group/session rows are harmless (nothing left points at them), so it's simpler and safer to just leave them and only delete the duplicateAttReportrows.Texts migration
Seeds the two new IVR texts via
1789587905258-UpdateYemotTextsSeminarDuplicateLesson.ts— same content as #191's migration, but with a realDate.now()timestamp instead of a rounded placeholder.SEMINAR.DUPLICATE_LESSON_PROMPTSEMINAR.DUPLICATE_LESSON_DELETEDTests
Test file adapted from #191: "add" (answer 1) unchanged; "delete" (answer 2) now asserts the prior
AttReportrows for that lesson are gone and fresh rows are saved, whileReportGroup/ReportGroupSessionrows are left untouched (no cascade cleanup anymore). Not re-run locally in this session (submodules/deps not initialized here).Supersedes #191.
🤖 Generated with Claude Code
https://claude.ai/code/session_01WER1oSuN8tCQTNRU73Mi89