fix(employee, invite): default the page size before computing the page offset

Merged
CE
7d ago
+158-14

Problem

EmployeeService.pagination (both ORMs) and InviteService.findAllInvites compute the offset as options.take * (options.skip - 1) before any default page size, so a request sending skip (the page number) without take got a NaN offset (TypeORM's skip() rejects it, MikroORM sends NaN).

Fix

  • Employee: the page comes from resolveRequestedPage, with take defaulting to 10 first; MikroORM gets offset / limit, TypeORM skip / take.
  • Invite: the page comes from resolveRequestedPage and is applied only with a valid take; otherwise the list stays unpaginated, as it was when neither was sent.

Tests

  • employee.service.pagination-default-take.spec.ts (TypeORM and MikroORM): skip: 3 alone → offset 20, limit 10; take: 25, skip: 3 → offset 50, limit 25; no page → offset 0, limit 10.
  • invite.service.find-all-pagination.spec.ts: skip alone → no page; take: 10, skip: 3 → skip 20, take 10; take alone → skip 0, take 10.

Notes

Not built or run locally.


Summary by cubic

Fixes pagination when a page number (skip) is sent without a page size (take), which previously produced a NaN offset on both ORMs.

  • EmployeeService.pagination now defaults the page size to 10 before computing the offset, on both TypeORM and MikroORM.
  • InviteService.findAllInvites now only paginates when a valid take is sent; otherwise the list stays unpaginated, as before.