Code RoomPage count truncates remainder
MediumPrep Room Coding #1993

Page count truncates remainder

Code reviewNetworking & APIsMid–Senior~20 min

Review this Java paginated ticket-list endpoint that returns a total page count the UI uses to render page buttons.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 20 min
Mark a line and say what kind of problem it is.0 findings
1@GetMapping("/tickets")
2public PageDto list(@RequestParam int page, @RequestParam(defaultValue="25") int size) {
3 long total = repo.count(); // SELECT COUNT(*)
4 int totalPages = (int) (total / size); // for the UI pager
5 List<Ticket> items = repo.findPage(page, size); // OFFSET page*size
6 return new PageDto(items, page, totalPages, total);
7}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.