Objective
- Let dispatchers run route optimization for charge-based calendar events (radon pickup/drop, sewer scope, equipment events, etc.) independently from inspection optimization.
- Use preview → accept/reject for proposed moves, with simpler constraints where appropriate.
- Compare tech/event routes without mixing inspection optimization complexity into the same run.
Background
- Inspections and events both appear on dispatch/calendar (
calendar.tsjoins events to charges;eventSchema.tslinks_chargeId,_inspectionId). - Events support
locked?: booleanonEventsType— immovable events must be honored. - Inspection optimize is scoped separately (ATT-813); charge-event optimize needs its own explicit action and endpoint.
- Attik job creation is the forward path; optimize targets Attik calendar data.
Product decisions
- Separate user action: Optimize events distinct from Optimize inspections.
- Same date/time range selector as inspection optimize.
- Scope: events with
_chargeId(charge-based); decision needed on standalonetype: 'Block'events in v1. - Respect time windows (hard/soft per event) and run-level optimize window (e.g. optimize 9 AM–12 PM only).
- Reuse Mapbox distance layer issue for all drive-time calculations.
Scope
Backend
- Query charge-linked events in range; build per-inspector sequences; optimize order/times within constraints.
- Update via existing event routes.
- Respect hard time windows; soft windows may move with API/UI warning before accept.
Frontend
- Dispatch UI (
attik-frontend/src/app/tools/dispatch/) — parallel Optimize events entry, preview, accept/cancel.
Acceptance criteria
- [ ] Optimize events moves only charge-based events in the selected range.
- [ ] Inspections are not moved by this action.
- [ ] Locked events (
locked: true) are not moved. - [ ] Hard time windows respected; soft violations warned before accept.
- [ ] Run-level window (e.g. 9–12) limits which events are in scope for the optimize run.
- [ ] Mapbox calls use shared distance layer.
References
attik-backend/src/models/eventSchema.tsattik-backend/src/routes/calendar.tsattik-frontend/src/app/tools/dispatch/DispatchCalendar.tsx