Skip to content

feat(gov): GET /gov/receipts/recent for activity card (PR 6c)#6

Merged
sidhujag merged 2 commits intomainfrom
gov-vote-analytics
Apr 21, 2026
Merged

feat(gov): GET /gov/receipts/recent for activity card (PR 6c)#6
sidhujag merged 2 commits intomainfrom
gov-vote-analytics

Conversation

@sidhujag
Copy link
Copy Markdown
Member

Summary

Backend companion for PR 6c on `sysnode-info` (syscoin/sysnode-info#9).

Adds a single authenticated endpoint backing the new "Your activity" card on the governance page:

  • `GET /gov/receipts/recent` — returns the current user's most recent vote receipts (limit clamped to `[1, 50]`, default 10). Authenticated + CSRF-guarded.
  • Backed by the existing `voteReceipts.listRecent`; no schema, migration, or RPC surface changes.

Tests

381 / 381 passing (21 suites). New cases cover:

  • 401 without a session
  • empty-state response
  • default limit (10) + custom limit (clamped at 50)
  • invalid limit → 400
  • user isolation (caller only sees their own receipts)
  • `submitted_at DESC` ordering — uses an injected monotonic clock on `createVoteReceiptsRepo` so rows landing in the same millisecond still order deterministically.

Test plan

  • `npm test` green.
  • Cast a vote from the sysnode-info UI (PR 9) and confirm the activity card refreshes with the new receipt on modal close.
  • Hit `GET /gov/receipts/recent` with `limit=100` and confirm it's clamped to 50 rows.
  • Hit it without a session cookie and confirm a 401.

Made with Cursor

New authenticated endpoint backing the "Your activity" card on the
governance page. Returns the user's most recent vote receipts
(limit clamped to [1, 50]) via voteReceipts.listRecent.

Tests use an injected monotonic clock on the repo so submitted-at
ordering is deterministic when rows land in the same millisecond.

Made-with: Cursor
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e37aae3e85

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread routes/gov.js Outdated
Comment on lines +424 to +425
const parsed = Number.parseInt(rawLimit, 10);
if (!Number.isInteger(parsed) || parsed <= 0) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Parse limit with strict numeric validation

Using Number.parseInt here accepts partially numeric strings (for example limit=2abc, limit=1.5, or limit=1e3) and silently coerces them instead of returning 400 invalid_limit. That makes malformed client requests look successful and can produce unexpected result counts, despite the route contract documenting an integer limit in [1, 50].

Useful? React with 👍 / 👎.

…x round 1)

Number.parseInt silently accepts partially-numeric strings
(limit=2abc → 2, limit=1.5 → 1, limit=1e3 → 1). The route
contract documents an integer in [1, 50] and clients depend on
that being enforced; malformed queries now 400 invalid_limit
instead of returning an arbitrary row count.

Made-with: Cursor
@sidhujag
Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@sidhujag
Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@sidhujag sidhujag merged commit 0a41c6d into main Apr 21, 2026
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.

1 participant