Skip to content

[#94] Add comment length validation and GET pagination#98

Merged
realproject7 merged 2 commits intomainfrom
task/94-comment-length-pagination
Mar 15, 2026
Merged

[#94] Add comment length validation and GET pagination#98
realproject7 merged 2 commits intomainfrom
task/94-comment-length-pagination

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

Fixes #94

  • Comment length validation: 500-char max enforced server-side (returns 400 if exceeded) and client-side via maxLength on textarea
  • GET pagination: Supports ?limit=N&offset=N params (default limit=20, max 100), returns total count alongside paginated results, ordered by updated_at descending
  • Rate limiting noted in the issue but excluded from checklist scope

Test plan

  • Submit a comment at exactly 500 chars — should succeed
  • Submit a comment over 500 chars via API — should return 400
  • Textarea should prevent typing beyond 500 chars
  • GET /api/ratings?storylineId=1 returns max 20 ratings with total field
  • GET /api/ratings?storylineId=1&limit=5&offset=0 returns 5 ratings

🤖 Generated with Claude Code

- Server-side 500-char comment limit with client-side maxLength
- GET endpoint now supports ?limit=N&offset=N pagination (default 20,
  max 100) with total count in response
- Results ordered by updated_at descending

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

T2b Review — APPROVE

Comment length validation (API + UI) and GET pagination both implemented correctly.

  • Server-side 500-char limit checked before signature verification ✓
  • maxLength={500} on textarea ✓
  • Pagination with limit (capped at 100), offset, total count, and updated_at desc ordering ✓

Note (non-blocking): average is now page-scoped, not global. The inline comment acknowledges this, but consumers relying on the average will get incorrect values once ratings exceed one page. Consider a separate aggregate query in a follow-up.

LGTM ✓

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

Verdict: REQUEST CHANGES

Summary

The comment-length validation is fine, but the pagination change introduces a correctness regression in the ratings API contract and the existing UI consumers.

Findings

  • [high] GET /api/ratings now computes average and count from only the current page, while existing consumers still use those fields as all-ratings metadata. Once a storyline has more than one page of ratings, both the summary and widget will display incorrect totals/averages.
    • File: src/app/api/ratings/route.ts:47
    • Suggestion: Keep average and the displayed total based on the full storyline dataset, not the paginated slice. If pagination needs extra metadata, add new fields like pageCount/total without changing the meaning of existing fields.
  • [medium] The widget prefill logic now only searches the first page of recent ratings, so a connected user with an older rating will appear unrated and can accidentally overwrite without seeing their current value.
    • File: src/components/RatingWidget.tsx:88
    • Suggestion: Preserve a way to fetch the current user's own rating independently of page slicing, or ensure the API response for the widget still includes that record regardless of pagination.

Decision

Requesting changes because the current pagination implementation breaks existing ratings displays and user prefill behavior for storylines with more than one page of ratings.

Average and count now computed from all ratings (not just the current
page). Added optional raterAddress param to GET for dedicated lookup
of the caller's own rating, used by RatingWidget for prefill.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

Verdict: APPROVE

Summary

The PR now adds the requested 500-character comment validation and GET pagination while preserving correct global rating metrics and widget prefill behavior.

Findings

  • No blocking findings.

Decision

Approving because the updated implementation matches issue #94, resolves the pagination regressions from the prior revision, and the refreshed lint/typecheck run passed.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

T2b Re-Review — APPROVE

Both issues resolved:

  • Average/count now computed from full dataset, not page-scoped ✓
  • Dedicated ?raterAddress= param for myRating lookup — widget prefill works regardless of pagination ✓
  • Query key includes address for proper refetch on wallet change ✓

LGTM ✓

@realproject7 realproject7 merged commit 72b4d6c into main Mar 15, 2026
1 check passed
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.

[Bug] No comment length limit or rate limiting on ratings API

2 participants