Repository navigation
Teacher reported today: card per lesson taught, per-lesson hour, fix missing-girls total - #204
Merged
Merged
Conversation
teacher_reported_today view column order and attendance_cleanup_rules lesson_id/klass_id nullability + active column type, so migration:generate reports no drift. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Po2GocBhFneXD2k9z1f6Ld
…missing-girls total
- missingGirlsCount comes from MySQL COUNT as a string; cast to Number so the
card total sums instead of concatenating ("012") and a zero badge is hidden.
- View now has one row per lesson taught: reports of the same
teacher+lesson+klass+date are split into separate lessons when more than
15 minutes pass between consecutive reports. Works for phone, web form
and Excel reports alike.
- reportHour is the first report time of that lesson.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Po2GocBhFneXD2k9z1f6Ld
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
SQLite gap comparison drops milliseconds, merging reports beyond 15-minute boundary.
Review effort: Balanced
Findings: 1
What changed in this PR
Updates teacher-report cards to show separate lessons with correct report times and absence counts.
Changes:
- Splits reports when consecutive gaps exceed 15 minutes.
- Uses each lesson’s first report time.
- Fixes numeric absence totals and hides zero badges.
| File | Description |
|---|---|
| server/src/migrations/1791306863767-SplitTeacherReportedTodayByLesson.ts | Applies lesson-splitting view and rollback. |
| server/src/db/view-entities/TeacherReportedToday.entity.ts | Defines gap-based grouping and per-lesson times. |
| client/src/entities/teacher-reported-today.jsx | Shows separate lesson cards and numeric absence counts. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…rt_date) index - teacher_reported_today: replace local sqlite check with shared helper (MySQL SQL unchanged). Bumps server/shared to nra-server claude/add-minutes-expression (buzz-code/nra-server#63); re-point to merged main before merging. - att_user_report_date_idx: the view and other date-range reports filter by user + report_date; only a user_id index existed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Po2GocBhFneXD2k9z1f6Ld
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Po2GocBhFneXD2k9z1f6Ld
…ed-today-per-lesson
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Po2GocBhFneXD2k9z1f6Ld
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
Fixes in the "מורות שדיווחו" (
teacher_reported_today) card view:Missing-girls total bug.
missingGirlsCountcomes from MySQLCOUNT(BIGINT) as a string, so the card total concatenated (0 + "1" + "2"→חסרו 012). It's now cast toNumber. The same string made a0badge show on lessons with no absences; that badge is hidden now.One card per lesson taught. The view now has one row per lesson. Reports of the same teacher + lesson + klass + date become separate lessons when more than 15 minutes pass between consecutive reports. Consecutive gaps are measured, not the time since the first report, so this works for every source:
The same subject at 09:00 and 11:30 → two cards. Two different subjects → two cards, as before.
Per-lesson report hour.
reportHouris the first report time of that lesson. Before, it was shared across all of a teacher's lessons in the klass that day.New index
att_user_report_date_idxonatt_reports (user_id, report_date). The view (and other date-range screens) filter by user + date, but only auser_idindex existed.The view is a raw SQL expression with window functions (
LAG→ new-lesson flag, runningSUM→ lesson number). The gap comparison uses the sharedgetAddMinutesExpressionhelper for the MySQL/SQLite difference; on SQLite it keeps milliseconds. The id usesgetConcatExpression. Migrations:SplitTeacherReportedTodayByLesson1791306863767(view)AddAttReportUserReportDateIndex1791317504779(index)Both were generated by TypeORM.
Performance
Local MySQL 8.0.46, 1M
att_reportsrows (10 users × 250 days). Query shaped like the client's: oneuserId, a date range,ORDER BY reportHour LIMIT 1000.userId/reportDatefilter is pushed down toatt_reportsin both views, so the view is never fully materialized.Testing
Local MySQL 8 + NestJS + Vite with seeded reports:
migration:generate --dryrunreports no drift.jest: 1171/1171. Clientjest: 214/214.🤖 Generated with Claude Code
https://claude.ai/code/session_01Po2GocBhFneXD2k9z1f6Ld