I was working on a take-home assessment for a staffing platform API — a NestJS + Prisma + SQLite application that managed workers, workplaces, and shifts.
The task was simple: implement two scripts that return the top 3 currently-active workplaces and workers by number of completed shifts.
Simple enough. Except the output was wrong.
The system
The API had three tables: Workers, Workplaces, and Shifts. Status was an integer enum — ACTIVE = 0, SUSPENDED = 1, CLOSED = 2. Shifts had a workerId (nullable), a cancelledAt (nullable) , and startAt/endAt timestamps. No explicit "completed" flag — you derive state from the fields.
List endpoints returned paginated responses with a links.next URL to follow, and a sharding system on top. The design was clean. The bug was quiet.
What wrong looked like
The scripts ran. They returned valid JSON. They just returned the wrong entities.…