Skip to content

Add cursor-based pagination for large tip history endpoints #67

Description

@nanaf6203-bit

Area: Database Performance
Priority: P2 — Medium

Description

Offset pagination becomes slow at high pages because the database must scan and skip all preceding rows. Cursor-based pagination is O(log n) and stable for new data. Replace offset with cursors on hot endpoints.

Acceptance Criteria

  • Add optional cursor query param to GET /tips/my/received, GET /tips/my/sent, GET /tips/wallet/:address
  • Cursor format: base64-url-encoded JSON {createdAt,id} tuple
  • Response includes nextCursor and previousCursor (omitted when no more data)
  • Backward-compatible: offset pagination (page/limit) still works
  • Implement using WHERE (createdAt, id) < (?, ?) for forward cursors
  • Tests verifying no duplicate/missed rows across cursor pages when new data appears
  • Document cursor API in README under API > Tips > Pagination

Technical Notes

  • Use Buffer.from(JSON.stringify({t,i})).toString('base64url') for encoding
  • Validate cursor shape; bad cursor → 400
  • Limit + 1 query trick to detect nextCursor presence

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignP2Critical priorityenhancementNew feature or requestprofilestips

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions