Skip to content

[Backend] Add status and date-range filters to getBorrowerLoans #889

Description

@ogazboiz

Join the contributor Telegram: https://t.me/+DOylgFv1jyJlNzM0

Why this matters

loanController.getBorrowerLoans returns paginated borrower loans, but only filters by borrower. Borrowers with longer histories want filtering by status (active, repaid, defaulted, liquidated, pending) and a date range. Without these, the loan list page is hard to use after even a few months of activity.

Acceptance criteria

  • Add status and from/to query params, validated with Zod.
  • Apply parameterised SQL filters and ensure the (borrower, status, created_at) index is present (file migration if not).
  • Update the cursor pagination to remain stable under filters.
  • Add Jest tests for 3 filter combinations including empty result.
  • Update the @swagger JSDoc.

Files to touch

  • backend/src/controllers/loanController.ts
  • backend/src/schemas/loanSchemas.ts
  • backend/src/routes/loanRoutes.ts
  • backend/migrations/ (only if a new index is needed)
  • backend/src/__tests__/loanEndpoints.test.ts

Out of scope

  • Adding the same filters to the admin endpoints.
  • Wiring the filter UI in the frontend (separate frontend issue).

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendIssues related to backend developmentgood first issueGood for newcomers

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