fix: resolve 4 UI/planning bugs from issue tracker
- Lock all maps to North America (no pan/zoom) in ProgressMapView and TripDetailView - Sort saved trips by most cities (stops count) - Filter cross-country trips to top 2 by stops on home screen - Use LocationSearchSheet for Follow Team home location (consistent with must-stop) - Initialize DateRangePicker to show selected dates on appear Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,7 @@ import CoreLocation
|
||||
///
|
||||
/// Input:
|
||||
/// - date_range: Required. The trip dates (e.g., Jan 5-15)
|
||||
/// - must_stop: Optional. A location they must visit (not yet implemented)
|
||||
/// - must_stop: Optional. A location they must visit (filters to home games in that city)
|
||||
///
|
||||
/// Output:
|
||||
/// - Success: Ranked list of itinerary options
|
||||
@@ -90,6 +90,37 @@ final class ScenarioAPlanner: ScenarioPlanner {
|
||||
)
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────────────────────
|
||||
// Step 2b: Filter by must-stop locations (if any)
|
||||
// ──────────────────────────────────────────────────────────────────
|
||||
// If user specified a must-stop city, filter to HOME games in that city.
|
||||
// A "home game" means the stadium is in the must-stop city.
|
||||
var filteredGames = gamesInRange
|
||||
if let mustStop = request.mustStopLocation {
|
||||
let mustStopCity = mustStop.name.lowercased()
|
||||
filteredGames = gamesInRange.filter { game in
|
||||
guard let stadium = request.stadiums[game.stadiumId] else { return false }
|
||||
let stadiumCity = stadium.city.lowercased()
|
||||
// Match if either contains the other (handles "Chicago" vs "Chicago, IL")
|
||||
return stadiumCity.contains(mustStopCity) || mustStopCity.contains(stadiumCity)
|
||||
}
|
||||
|
||||
if filteredGames.isEmpty {
|
||||
return .failure(
|
||||
PlanningFailure(
|
||||
reason: .noGamesInRange,
|
||||
violations: [
|
||||
ConstraintViolation(
|
||||
type: .mustStop,
|
||||
description: "No home games found in \(mustStop.name) during selected dates",
|
||||
severity: .error
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────────────────────
|
||||
// Step 3: Find ALL geographically sensible route variations
|
||||
// ──────────────────────────────────────────────────────────────────
|
||||
@@ -112,7 +143,7 @@ final class ScenarioAPlanner: ScenarioPlanner {
|
||||
|
||||
// Global beam search (finds cross-region routes)
|
||||
let globalRoutes = GameDAGRouter.findAllSensibleRoutes(
|
||||
from: gamesInRange,
|
||||
from: filteredGames,
|
||||
stadiums: request.stadiums,
|
||||
allowRepeatCities: request.preferences.allowRepeatCities,
|
||||
stopBuilder: buildStops
|
||||
@@ -121,7 +152,7 @@ final class ScenarioAPlanner: ScenarioPlanner {
|
||||
|
||||
// Per-region beam search (ensures good regional options)
|
||||
let regionalRoutes = findRoutesPerRegion(
|
||||
games: gamesInRange,
|
||||
games: filteredGames,
|
||||
stadiums: request.stadiums,
|
||||
allowRepeatCities: request.preferences.allowRepeatCities
|
||||
)
|
||||
@@ -130,7 +161,7 @@ final class ScenarioAPlanner: ScenarioPlanner {
|
||||
// Deduplicate routes (same game IDs)
|
||||
validRoutes = deduplicateRoutes(validRoutes)
|
||||
|
||||
print("🔍 ScenarioA: gamesInRange=\(gamesInRange.count), validRoutes=\(validRoutes.count)")
|
||||
print("🔍 ScenarioA: filteredGames=\(filteredGames.count), validRoutes=\(validRoutes.count)")
|
||||
if let firstRoute = validRoutes.first {
|
||||
print("🔍 ScenarioA: First route has \(firstRoute.count) games")
|
||||
let cities = firstRoute.compactMap { request.stadiums[$0.stadiumId]?.city }
|
||||
|
||||
Reference in New Issue
Block a user