Skip to content

GET /admin/disputes paginates in memory after loading every dispute #504

Description

@Omoboi-dev

Category: Performance
Difficulty: Medium

Description

AdminDisputeService.getDisputes accepts page and limit, then does:

const allDisputes = await this.prisma.dispute.findMany({ where: ... });
const total = allDisputes.length;
const data = allDisputes.slice(start, start + limit);

The where narrows by status when one is supplied, but there is no skip, no take and no
orderBy. Page 1 of 20 costs the same as fetching every dispute, and the ordering is whatever the
database returns, so a row can appear on two pages or on none as data changes between requests.

Location

  • src/admin/dispute/dispute.service.ts
  • src/admin/dispute/dispute.controller.ts
  • test/integration/admin-disputes.integration-spec.ts

Example commits

perf(admin): paginate disputes in the database
test(admin): assert stable ordering across pages

Acceptance Criteria

  • The query uses skip, take and a deterministic orderBy.
  • total comes from a count against the same where.
  • page and limit are validated: rejected or clamped when below 1, and limit has an upper bound.
  • Tests are required. Assert that consecutive pages of a known dataset are disjoint and together cover it.

Technical Notes

The in-memory PrismaService needs skip/take/orderBy support for dispute.findMany if it
does not have it; add it rather than special-casing the service.
Out of scope: changing the response envelope.


Before you start

  • Set up with the steps in CONTRIBUTING.md. Node 22 is required (.nvmrc), use npm ci rather than npm install, and copy .env.example to .env before running npx prisma generate — the Prisma config reads DATABASE_URL at load.
  • Branch from dev and open your pull request against dev. main is the released baseline.
  • Tests that need an authenticated caller should use the bearer() helper in test/auth-helper.ts, which mints a genuinely signed SEP-10 token. Do not send a raw Stellar address as a bearer token; that path was removed deliberately.
  • You may cover more than one issue in a single pull request.

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programcomplexity: medium150 pts. New endpoint, service method, integration testperformanceperformance

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions