fix(employee, invite): default the page size before computing the page offset
Merged
CE
7d ago+158+158+012345678901234567890123456789-14-14-01234567890123456789
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, withtakedefaulting to 10 first; MikroORM getsoffset/limit, TypeORMskip/take. - Invite: the page comes from
resolveRequestedPageand is applied only with a validtake; otherwise the list stays unpaginated, as it was when neither was sent.
Tests
employee.service.pagination-default-take.spec.ts(TypeORM and MikroORM):skip: 3alone → 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:skipalone → no page;take: 10, skip: 3→ skip 20, take 10;takealone → 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.paginationnow defaults the page size to 10 before computing the offset, on both TypeORM and MikroORM.InviteService.findAllInvitesnow only paginates when a validtakeis sent; otherwise the list stays unpaginated, as before.