Skip to content

feat: add getAddMinutesExpression database-agnostic helper - #63

Merged
buzz-code merged 2 commits into
mainfrom
claude/add-minutes-expression
Oct 7, 2026
Merged

buzz-code merged 2 commits into
mainfrom
claude/add-minutes-expression

Conversation

@buzz-code

@buzz-code buzz-code commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds getAddMinutesExpression(column, minutes) to utils/entity/column-types.util.ts, next to getConcatExpression and getGroupConcatExpression:

  • MySQL: column + INTERVAL n MINUTE
  • SQLite (tests): strftime('%Y-%m-%d %H:%M:%f', column, '+n minutes'). It uses strftime with %f instead of datetime() so milliseconds are kept, and negative values become '-n minutes'.

The change only adds a new export, so no CONSUMER_CHANGES.md row is needed.

First consumer is the teacher_reported_today view in buzz-code/react-admin-nestjs#204, which splits reports into lessons by gaps between report times. Using the helper replaces a hand-rolled databaseConfig.type === 'sqlite' check in that project.

Testing

  • New specs in column-types.util.spec.ts cover both dialects and negative minutes. The MySQL branch is tested via an isolated module with a mocked databaseConfig.
  • I checked the SQLite expression against a real SQLite DB: 09:00:00.100 + 15 min = 09:15:00.100, and -15 subtracts.
  • I ran the full react-admin-nestjs server suite against this branch: 1171/1171 pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Po2GocBhFneXD2k9z1f6Ld

MySQL: column + INTERVAL n MINUTE. SQLite: datetime(column, '+n minutes').

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Po2GocBhFneXD2k9z1f6Ld
Copilot AI balanced review requested due to automatic review settings October 6, 2026 20:15
buzz-code pushed a commit to buzz-code/react-admin-nestjs that referenced this pull request Oct 6, 2026
…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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Negative minute values generate an invalid SQLite modifier and return NULL.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds a database-agnostic SQL helper for minute-based datetime arithmetic.

Changes:

  • Adds MySQL and SQLite expression generation.
  • Adds dialect-specific unit tests.
File Description
utils/​entity/​column-types.util.ts Adds the datetime arithmetic helper.
utils/​entity/​__tests__/​column-types.util.spec.ts Tests SQLite and MySQL output.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread utils/entity/column-types.util.ts Resolved
…xpression on SQLite

datetime() truncates fractional seconds, and '+-15 minutes' is invalid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Po2GocBhFneXD2k9z1f6Ld
@buzz-code
buzz-code merged commit d65b429 into main Oct 7, 2026
buzz-code pushed a commit to buzz-code/react-admin-nestjs that referenced this pull request Oct 7, 2026
buzz-code added a commit to buzz-code/react-admin-nestjs that referenced this pull request Oct 7, 2026
…missing-girls total (#204)

* Align DB schema with TypeORM entities

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

* Teacher reported today: card per lesson taught, per-lesson hour, fix 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

* Use shared getAddMinutesExpression and add att_reports (user_id, report_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

* Bump server/shared: getAddMinutesExpression keeps milliseconds on SQLite

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Po2GocBhFneXD2k9z1f6Ld

* Bump server/shared to nra-server main (buzz-code/nra-server#63 merged)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Po2GocBhFneXD2k9z1f6Ld

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants