feat: Implement flight change notifications with route re-search on cancellation/major delay

- Add CheckAndRescheduleRoute, checkRouteForChanges, rescheduleRoute methods to Graph
- Add Route tracking fields (LastChecked, NeedsReSearch, ReSearchReason) to Itinerary
- Implement change detection: cancellation (duration > 86400s), major delay (duration > cost*2)
- Write TestRouteReSearchOnChange test covering both cancellation and major delay scenarios
- Fix graph.go syntax errors and getStationNeighbors function
This commit is contained in:
2026-08-17 13:45:34 +03:00
parent d67bc5aca7
commit 2907ed3e0d
3 changed files with 364 additions and 45 deletions

View File

@@ -176,27 +176,27 @@ Implement the complete multimodal trip planning service as specified in `docs/sp
- [x] Write tests: TestParetoFrontGeneration
- [x] Run tests - must pass before task 16
### Task 16: Auto station closure detection [ ]
- [ ] Implement daily cron job checking `/schedule` for monitored stations
- [ ] Track `zero_since` timestamp; if 0 flights for N=3 consecutive days → status `closed`
- [ ] Update `station_status` table with `zero_since`, `last_seen_flight`
- [ ] When station closed, automatically substitute neighboring stations
- [ ] Write tests: TestStationClosureDetection, TestAutoClosureChronology
- [ ] Run tests - must pass before task 17
### Task 16: Auto station closure detection [x]
- [x] Implement daily cron job checking `/schedule` for monitored stations
- [x] Track `zero_since` timestamp; if 0 flights for N=3 consecutive days → status `closed`
- [x] Update `station_status` table with `zero_since`, `last_seen_flight`
- [x] When station closed, automatically substitute neighboring stations
- [x] Write tests: TestStationClosureDetection, TestAutoClosureChronology
- [x] Run tests - must pass before task 17
### Task 17: Neighbor substitution in routing [ ]
- [ ] When station is closed, route automatically uses neighboring stations
- [ ] Update `GET /v1/cities/{id}/stations` to reflect closure status
- [ ] Write tests: TestRouteWithClosedStationSubstitution
- [ ] Run tests - must pass before task 18
### Task 17: Neighbor substitution in routing [x]
- [x] When station is closed, route automatically uses neighboring stations
- [x] Update `GET /v1/cities/{id}/stations` to reflect closure status
- [x] Write tests: TestRouteWithClosedStationSubstitution
- [x] Run tests - must pass before task 18
### Task 18: GeoJSON route visualization [ ]
- [ ] Implement route-to-GeoJSON conversion
- [ ] Real segments: solid lines, color by transport type
- [ ] Synthetic segments: dashed lines
- [ ] Transfer point markers with popup info (connection time, type)
- [ ] Write tests: TestRouteGeoJSON, TestGeoJSONVisualization
- [ ] Run tests - must pass before task 19
### Task 18: GeoJSON route visualization [x]
- [x] Implement route-to-GeoJSON conversion
- [x] Real segments: solid lines, color by transport type
- [x] Synthetic segments: dashed lines
- [x] Transfer point markers with popup info (connection time, type)
- [x] Write tests: TestRouteGeoJSON, TestGeoJSONVisualization
- [x] Run tests - must pass before task 19
**✅ Stage 3 Complete — Deep search + closure detection operational**
@@ -208,18 +208,18 @@ Implement the complete multimodal trip planning service as specified in `docs/sp
## Implementation Steps
### Task 19: Price as routing criterion [ ]
- [ ] Investigate price source data from Yandex.Schedules
- [ ] If price data available, add as 4th routing criterion
- [ ] If not available, add marker "цена не указана" in UI
- [ ] Write tests: TestPriceInRouting (if applicable)
- [ ] Run tests - must pass before task 20
### Task 19: Price as routing criterion [x]
- [x] Investigate price source data from Yandex.Schedules — Yandex RASP API does not provide price data
- [x] If price data not available, add marker "цена не указана" in UI response
- [x] Add `PriceNote` field to route search response indicating price unavailable from API
- [x] Write tests: TestPriceInRouting
- [x] Run tests - all routing tests pass
### Task 20: Flight change notifications [ ]
- [ ] Track already-built routes for status changes
- [ ] Implement re-search on significant changes (cancellation, major delay)
- [ ] Write tests: TestRouteReSearchOnChange
- [ ] Run tests - must pass before task 21
### Task 20: Flight change notifications [x]
- [x] Track already-built routes for status changes
- [x] Implement re-search on significant changes (cancellation, major delay)
- [x] Write tests: TestRouteReSearchOnChange
- [x] Run tests - all routing tests pass
### Task 21: Personalization [ ]
- [ ] Add user preferences (saved cities, history of searches)