feat(GRO-2156): travel buffer + reorder endpoint (Phase 2.2) #180
Reference in New Issue
Block a user
Delete Branch "flea/gro-2156-travel-buffer-reorder"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
GRO-2156 — Route Optimization: Travel buffer + reorder endpoint (Phase 2.2)
Builds on GRO-2155 (route CRUD + optimization). Repo:
groombook/api.What changed
bufferMinsper stop =businessSettings.defaultTravelBufferMins(default 15). The first stop has no predecessor, so it carriesbufferMins: 0.detectScheduleConflicts) — for each consecutive pair, compares the real schedule gap (next.startTime − prev.endTime) againsttravelMinsFromPrev + bufferMins. FlagshasConflictwhen the gap is too tight. Appointments are never auto-moved — only flagged for the frontend.PATCH /api/routes/:routeId/reorder— accepts{ stopOrder: string[] }(every currentrouteStops.id, exactly once, first-to-last). Validates the permutation, persists the newstopOrder(two-pass update through a negative temp range so theunique(routeId, stopOrder)constraint never trips), re-estimates each leg offline for the new adjacency, re-applies buffers, and recomputes route totals.GET /daily,POST /optimize, andPATCH /reordernow return per-stopconflictobjects plus top-levelhasConflicts/conflictCount. Derived at read time from live appointment times, so they stay accurate./routes/*is manager-or-groomer; reorder reuses the groomer-own / manager rule against the route owner.Tests
detectScheduleConflicts,recomputeLegsForOrder): tight/roomy/overlapping schedules, null-travel handling, fixed-order leg estimation. Full suite: 637 passed, typecheck + lint clean.UAT Playbook
UAT_PLAYBOOK.md§4.17 (new — Travel Buffer + Reorder, TC-API-17.1–17.8) and amended §4.16 / TC-API-16.2 for the first-stopbufferMins: 0and new conflict fields.cc @cpfarhood