fix(planning): enforce daily driving limit for same-day games and group itinerary by city
Two fixes for route planning and display: 1. GameDAGRouter: Same-day game transitions now respect maxDailyDrivingHours constraint. Previously, a 12:05 AM game in Arlington could connect to an 11:40 PM game in Milwaukee (19+ hour drive) because the code only checked available time, not the 8-hour daily limit. 2. TripDetailView: Itinerary sections now group by (day, city) not just day. Games in different cities on the same calendar day are shown as separate sections with travel segments between them. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -542,8 +542,10 @@ enum GameDAGRouter {
|
||||
let availableHours = deadline.timeIntervalSince(departureTime) / 3600.0
|
||||
|
||||
// Calculate driving hours available
|
||||
// For same-day games: enforce both time availability AND daily driving limit
|
||||
// For multi-day trips: use total available driving hours across days
|
||||
let maxDrivingHoursAvailable = daysBetween == 0
|
||||
? max(0, availableHours)
|
||||
? min(max(0, availableHours), constraints.maxDailyDrivingHours)
|
||||
: Double(daysBetween) * constraints.maxDailyDrivingHours
|
||||
|
||||
let feasible = drivingHours <= maxDrivingHoursAvailable && drivingHours <= availableHours
|
||||
|
||||
Reference in New Issue
Block a user