Repository navigation
Phone-per-class Yemot flow: class phone, teacher code - #158
Conversation
Classes now get their own fixed phone number instead of being identified by teacher caller ID: - Klass.phone (new, nullable) - the classroom's fixed phone number - Teacher.number (new, nullable) - short code teachers key in on the call - Seminar attendance call resolves the class from the caller's number, then asks for the teacher code instead of matching caller ID to a teacher's own phone - Star (*) during the teacher-code prompt falls back to manual class selection (existing klass-key flow) - lessonReferenceId is now filled from a matching LessonSchedule only when it belongs to the resolved class (previously the schedule chose the class directly) Excludes the auto-number-students bulk action (separate follow-up). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HXGT749AjJ6BDgDqvQXQX2
There was a problem hiding this comment.
🟡 Changes recommended
Missing uniqueness enforcement for new lookup keys (Klass.phone, Teacher.number) can make Yemot resolution nondeterministic in real data.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Shift Yemot seminar-attendance identification from teacher caller-ID to klass fixed phone + teacher keyed code, plus schema/UI support for new fields.
Changes:
- Add
Klass.phoneandTeacher.numbercolumns, expose in admin UI + translations. - Update Yemot seminar flow: resolve klass by caller phone, prompt teacher code, allow
*escape to manual klass select. - Update Yemot seminar test scenarios and add Yemot texts migration for new prompts.
File summaries
| File | Description |
|---|---|
| server/src/yemot-handler.service.ts | Switch seminar flow to klass-by-phone + teacher-code prompt; guard schedule lessonReferenceId by klass match |
| server/src/yemot-handler.service.test.ts | Rewrite seminar scenarios for new phone-per-class + teacher-code flow |
| server/src/migrations/1787300000000-AddKlassPhoneAndTeacherNumber.ts | Add DB columns + indexes for klass phone and teacher number |
| server/src/migrations/1787300000001-UpdateYemotTextsTeacherCode.ts | Seed new Yemot text keys for teacher-code prompt + invalid-code message |
| server/src/entity-modules/teacher.config.ts | Add teacher number field to config list |
| server/src/db/entities/Teacher.entity.ts | Add number column + index metadata |
| server/src/db/entities/Klass.entity.ts | Add phone column + index metadata |
| client/src/entities/teacher.jsx | Show/edit/import teacher number in React-Admin |
| client/src/entities/klass.jsx | Show/edit/import klass phone in React-Admin |
| client/src/domainTranslations.js | Add field translations for klass phone + teacher number |
Review details
Suppressed comments (1)
server/src/migrations/1787300000000-AddKlassPhoneAndTeacherNumber.ts:22
teachers_user_id_number_idxindex is non-unique, but Yemot flow authenticates teacher byTeacher.numberusingfindOneBy. Duplicatenumbervalues under same user will resolve to arbitrary teacher, breaking attendance reporting. Add unique constraint (and align entity decorator/validation) so teacher-code lookup is deterministic.
await queryRunner.query(`
ALTER TABLE \`teachers\`
ADD INDEX \`teachers_user_id_number_idx\` (\`user_id\`, \`number\`)
`);
- Files reviewed: 10/10 changed files
- Comments generated: 5
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Per Copilot review: Yemot resolution looked up both fields with no DB or app-level uniqueness guarantee, so a duplicate would resolve to an arbitrary row. - Klass.phone: unique per (userId, phone, year), matching the year scope getKlassByPhone() already queries with - Teacher.number: unique per (userId, number), matching the existing (year-agnostic) teacher lookup convention - Added matching @IsUniqueCombination validators for a Hebrew duplicate-value error in the admin UI, and unique() on the klass phone input (teacher number already had it) Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HXGT749AjJ6BDgDqvQXQX2
There was a problem hiding this comment.
🟡 Changes recommended
Nullable unique fields (Teacher.number, Klass.phone) can be saved as empty string from UI/import, causing duplicate-key failures and blocking creation of multiple rows with “blank” values.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 10/10 changed files
- Comments generated: 6
- Review effort level: Lite
Per Copilot review: a blank React-Admin TextInput submits '', and MySQL's unique index treats '' as a real (colliding) value unlike NULL - so a second klass/teacher left without a phone/number would hit a raw DB unique-constraint error instead of just saving fine. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HXGT749AjJ6BDgDqvQXQX2
Summary
Classes now get their own fixed phone number instead of being identified by teacher caller ID:
Klass.phone(new, nullable) — the classroom's fixed phone numberTeacher.number(new, nullable) — short code teachers key in on the call, instead of ID*) during the teacher-code prompt falls back to manual class selection (existing klass-key flow)lessonReferenceIdis now filled from a matchingLessonScheduleonly when it belongs to the resolved class (previously the schedule chose the class directly)Not included
The auto-number-students bulk action (assign sequential student numbers per class) is a separate follow-up, not part of this PR.
Testing
Rewrote
server/src/yemot-handler.service.test.ts's seminar-attendance scenarios for the new flow (class-by-phone happy path, star-escape to manual class, invalid teacher code retry, schedule-matches-wrong-class guard, plus the existing happy-path/edge-case coverage). Could not runyarn testin this sandbox (nonode_modules/submodules installed) — please run the suite in CI/locally before merging.Generated by Claude Code