Skip to content

backend(routes): notifications endpoints missing pagination, returns all notifications in a single query #661

@ogazboiz

Description

@ogazboiz

Join our community: https://t.me/+DOylgFv1jyJlNzM0

Description

The notifications routes fetch all notifications for a user without pagination. As users accumulate notifications over time (loan updates, repayment reminders, governance alerts), the query will return an ever-growing response payload. A user with 10,000 notifications would receive all of them in a single API call.

Similar pagination was implemented for loans and remittances with cursor-based pagination, but notifications were not updated to match.

Expected Behavior

Apply the same cursor-based pagination pattern already used in getRemittances() to the notifications endpoint:

  • Accept ?cursor=<timestamp> and ?limit=<n> query parameters
  • Default to limit=20, max limit=100
  • Return a nextCursor field in the response
  • Add an index on (user_id, created_at DESC) in the notifications table if not present

Impact

Medium. A high-activity user will experience slow notification loads and large payloads that degrade the API response time for the entire backend.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions