REPOSITORY CODING · MEDIUM
Split paid intervals before applying weekly overtime
A shift crossing a week boundary consumes the previous week allowance, producing false overtime. Partition each paid UTC interval at week boundaries before summing per-person totals; breaks and negative weeks must retain their meaning.
Repository ImplementationCivil-time roster and payroll rehearsal
Work through a real codebase.
Choose an environment, investigate the existing implementation and use the tests to check your change. Sign in to open a workspace; execution and Ono usage follow your plan’s allowances.
Task requirements and environments
Ruby on Rails · 55 minute session
- Resolve local-minute shift endpoints against an explicit offset-transition table. Each transition gives a UTC minute and the offset in minutes that starts there. The initial offset applies before the first transition. The table is strictly increasing, offsets are bounded, and no timezone or network service is consulted.
- A local time may have zero, one or two UTC candidates. Reject nonexistent times; ambiguous times require fold=earlier or fold=later, otherwise reject. A shift ends strictly after it starts and lasts at most 20160 elapsed minutes. Different workers may overlap, but shifts for the same person may not overlap.
- Unpaid breaks are half-open elapsed-minute offsets from the resolved UTC shift start. Validate them against actual elapsed duration, not wall-clock duration. Merge overlapping or repeated breaks before subtracting them; touching breaks are equivalent to their union.
- Split paid UTC intervals at epoch-aligned 10080-minute week boundaries, including negative weeks. Each person receives a separate regularMinutes allowance per week; remaining paid minutes are overtime. Output shifts by ID and weekly totals by person then week. The Rails API can save and retrieve rehearsal reports through tenant-scoped editions.