Page the admin inbox without skipping messages that share a millisecond (#138) - #116
Conversation
|
| const micros = (CURSOR_FRACTION_RE.exec(iso)?.[1] ?? "").padEnd(6, "0").slice(3) | ||
| return { at, instant: at.toISOString().replace(/Z$/, `${micros}Z`) } |
There was a problem hiding this comment.
A composite cursor issued before this change contains only milliseconds. This code pads a legacy value such as .123Z to .123000Z, and the new descending keyset queries then use that reconstructed value as an exact microsecond anchor. Continuing from a cursor for a row at .123900Z omits an older row at .123100Z, so operators continuing an existing inbox page after deployment can permanently miss messages. Keep millisecond-compatible continuation behavior for legacy composite cursors while using precise instants for newly emitted cursors.
Artifacts
Legacy cursor integration test
- The exact focused test source seeds microsecond-separated rows and compares exact versus legacy cursor continuation; it exercises both affected repositories.
Exact-microsecond cursor control
- Executed PostgreSQL integration test output for cursor anchors that preserve `.123900Z`; both inbound and inbox-feed continuations return all expected rows.
Legacy millisecond cursor failure
- Executed PostgreSQL integration test output for legacy `.123Z|UUID` cursors; both repository paths omit the row at `.123100Z`, confirming the defect.
Combined cursor integration run
- Executed all four focused database cases together; exact-microsecond controls pass and legacy-millisecond cases fail, confirming the incompatible behavior.
Ran code and verified through T-Rex
Prompt To Fix With AI
This is a comment left during a code review.
Path: services/api/src/db/cursor-helpers.ts
Line: 35-36
Comment:
**Preserve legacy cursor pages**
A composite cursor issued before this change contains only milliseconds. This code pads a legacy value such as `.123Z` to `.123000Z`, and the new descending keyset queries then use that reconstructed value as an exact microsecond anchor. Continuing from a cursor for a row at `.123900Z` omits an older row at `.123100Z`, so operators continuing an existing inbox page after deployment can permanently miss messages. Keep millisecond-compatible continuation behavior for legacy composite cursors while using precise instants for newly emitted cursors.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Comments Outside DiffThese findings sit on lines the diff does not cover, so they could not be posted inline. Each one leaves this list once its file changes.
|
Part of civfix/issue-tracker#138
What changed
Paging through the admin inbox with "Load more" no longer skips or repeats a message that arrived in the same millisecond as the last one on the page. Admin.
Before you start
mainpushVerify
[Admin]
Regression
Dashboard mail preview — [Admin]
Paging other admin lists — [Admin]
Not covered