As reported: Toast senior software engineer loop (Q4 2025), round 2 (REST API coding): build endpoints for a labor service that tracks when restaurant employees are on the job — data used for payroll hours, scheduling and user-facing products. Endpoints: clock an employee in; clock an employee out; list the employees currently clocked in; return how many hours an employee worked this week (the last 7 days), for example 30.5.
Design the REST API and implement the service behind it.
The code runner tests the service layer through this interface (timestamps are whole minutes and never decrease):
clockIn(employeeId, timestamp)→true, orfalseif the employee is already clocked in.clockOut(employeeId, timestamp)→true, orfalseif the employee is not clocked in ortimestampis before their clock-in.clockedIn()→ the ids of employees currently clocked in, sorted.hoursThisWeek(employeeId, now)→ hours worked within the last 7 days, the window(now − 10080, now]. Shifts that started before the window count only their part inside it; a shift still open counts up tonow. Unknown employees have worked 0 hours.
The runner prints hoursThisWeek rounded to two decimals (e.g. "30.50").
Example
clockIn("e2", 540) -> true
clockIn("e1", 600) -> true
clockIn("e2", 700) -> false (already on the clock)
clockedIn() -> ["e1", "e2"]
clockOut("e2", 1050) -> true (510 minutes)
clockOut("e1", 1110) -> true
hoursThisWeek("e2", 1200) -> 8.50
clockIn("e2", 2000) -> true
hoursThisWeek("e2", 2090) -> 10.00 (8.5 h + the open shift's 1.5 h)
clockedIn() -> ["e2"]
hoursThisWeek("e2", 11000) -> 152.17 (only minutes 920–1050 of the first shift are in the window)
Code runner format: LeetCode design format — method names and arguments as two JSON lines; the runner prints every result (null for the constructor).