fix: resolve travel anchor ID collision for repeat city pairs

Include segment index in travel anchor IDs ("travel:INDEX:from->to")
so Follow Team trips visiting the same city pair multiple times get
unique, independently addressable travel segments. Prevents override
dictionary collisions and incorrect validDayRange lookups.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-02-11 10:57:53 -06:00
parent 633f7d883f
commit ff6f4b6c2c
12 changed files with 291 additions and 79 deletions

View File

@@ -24,12 +24,13 @@ enum TravelPlacement {
/// - Parameters:
/// - trip: The trip containing stops and travel segments.
/// - tripDays: Array of dates (one per trip day, start-of-day normalized).
/// - Returns: Dictionary mapping day number (1-based) to TravelSegment.
/// - Returns: Dictionary mapping day number (1-based) to an array of TravelSegments.
/// Multiple segments can land on the same day (e.g. back-to-back single-game stops).
static func computeTravelByDay(
trip: Trip,
tripDays: [Date]
) -> [Int: TravelSegment] {
var travelByDay: [Int: TravelSegment] = [:]
) -> [Int: [TravelSegment]] {
var travelByDay: [Int: [TravelSegment]] = [:]
for (segmentIndex, segment) in trip.travelSegments.enumerated() {
let minDay: Int
@@ -63,7 +64,7 @@ enum TravelPlacement {
clampedDefault = max(1, min(defaultDay, tripDays.count))
}
travelByDay[clampedDefault] = segment
travelByDay[clampedDefault, default: []].append(segment)
}
return travelByDay