All problems

Rounding Each Cart Route Segment Inflates the Total ETA

Level 2 · node · Correctness · Accumulated ETA error from per-segment minute rounding

Scenario

A fictional indoor transport cart system divides routes into travel segments. Segment durations are stored in seconds, while the operations display shows the total trip duration as whole minutes. The current calculator rounds each segment up before summing, inflating the ETA for routes with many short segments. Trace the calculation across the repository, service, and controller.

Requirements

Sum the original segment durations in seconds and round up to whole minutes only once for the total. Keep the existing lookup and summary APIs, preserve original segment durations, return zero for an empty route, and reject negative or non-finite durations. Do not add external packages.

Acceptance criteria

  • Sum all segment durations in seconds before applying minute rounding once to the total.
  • A route whose total is an exact multiple of 60 seconds keeps its exact minute count.
  • A route with no segments takes zero minutes.
  • One segment between 1 and 59 seconds is displayed as one minute.
  • Route summaries preserve each original duration in seconds without modification.
  • Negative or non-finite segment durations are rejected with RangeError.