refactor: change domain model IDs from UUID to String canonical IDs

This refactor fixes the achievement system by using stable canonical string
IDs (e.g., "stadium_mlb_fenway_park") instead of random UUIDs. This ensures
stadium mappings for achievements are consistent across app launches and
CloudKit sync operations.

Changes:
- Stadium, Team, Game: id property changed from UUID to String
- Trip, TripStop, TripPreferences: updated to use String IDs for games/stadiums
- CKModels: removed UUID parsing, use canonical IDs directly
- AchievementEngine: now matches against canonical stadium IDs
- All test files updated to use String IDs instead of UUID()

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-01-12 09:24:33 -06:00
parent 4b2cacaeba
commit 1703ca5b0f
53 changed files with 642 additions and 727 deletions

View File

@@ -29,7 +29,7 @@ struct ItineraryBuilderTests {
@Test("Single stop creates itinerary with one stop and no travel segments")
func test_builder_SingleGame_CreatesSingleDay() {
// Arrange
let gameId = UUID()
let gameId = "game_test_\(UUID().uuidString)"
let stop = makeItineraryStop(
city: "New York",
state: "NY",
@@ -60,9 +60,9 @@ struct ItineraryBuilderTests {
func test_builder_MultiCity_CreatesTravelSegmentsBetween() {
// Arrange
let stops = [
makeItineraryStop(city: "Boston", state: "MA", coordinate: boston, games: [UUID()]),
makeItineraryStop(city: "New York", state: "NY", coordinate: nyc, games: [UUID()]),
makeItineraryStop(city: "Chicago", state: "IL", coordinate: chicago, games: [UUID()])
makeItineraryStop(city: "Boston", state: "MA", coordinate: boston, games: ["game_boston_\(UUID().uuidString)"]),
makeItineraryStop(city: "New York", state: "NY", coordinate: nyc, games: ["game_nyc_\(UUID().uuidString)"]),
makeItineraryStop(city: "Chicago", state: "IL", coordinate: chicago, games: ["game_chicago_\(UUID().uuidString)"])
]
// Act
@@ -103,8 +103,8 @@ struct ItineraryBuilderTests {
func test_builder_SameCity_MultipleGames_GroupsOnSameDay() {
// Arrange - Two stops in the same city (different games, same location)
let stops = [
makeItineraryStop(city: "New York", state: "NY", coordinate: nyc, games: [UUID()]),
makeItineraryStop(city: "New York", state: "NY", coordinate: nyc, games: [UUID()])
makeItineraryStop(city: "New York", state: "NY", coordinate: nyc, games: ["game_nyc_1_\(UUID().uuidString)"]),
makeItineraryStop(city: "New York", state: "NY", coordinate: nyc, games: ["game_nyc_2_\(UUID().uuidString)"])
]
// Act
@@ -141,8 +141,8 @@ struct ItineraryBuilderTests {
// Boston to Chicago is ~850 miles haversine, ~1100 with road factor
// At 60 mph, that's ~18 hours = 3 travel days (ceil(18/8) = 3)
let stops = [
makeItineraryStop(city: "Boston", state: "MA", coordinate: boston, games: [UUID()]),
makeItineraryStop(city: "Chicago", state: "IL", coordinate: chicago, games: [UUID()])
makeItineraryStop(city: "Boston", state: "MA", coordinate: boston, games: ["game_boston_\(UUID().uuidString)"]),
makeItineraryStop(city: "Chicago", state: "IL", coordinate: chicago, games: ["game_chicago_\(UUID().uuidString)"])
]
// Use constraints that allow long trips
@@ -192,7 +192,7 @@ struct ItineraryBuilderTests {
city: "Boston",
state: "MA",
coordinate: boston,
games: [UUID()],
games: ["game_boston_\(UUID().uuidString)"],
departureDate: now
)
@@ -201,7 +201,7 @@ struct ItineraryBuilderTests {
city: "New York",
state: "NY",
coordinate: nyc,
games: [UUID()],
games: ["game_nyc_\(UUID().uuidString)"],
firstGameStart: gameStartSoon
)
@@ -231,7 +231,7 @@ struct ItineraryBuilderTests {
city: "Boston",
state: "MA",
coordinate: boston,
games: [UUID()],
games: ["game_boston_\(UUID().uuidString)"],
departureDate: now
)
@@ -239,7 +239,7 @@ struct ItineraryBuilderTests {
city: "New York",
state: "NY",
coordinate: nyc,
games: [UUID()],
games: ["game_nyc_\(UUID().uuidString)"],
firstGameStart: gameLater
)
@@ -283,7 +283,7 @@ struct ItineraryBuilderTests {
city: String,
state: String,
coordinate: CLLocationCoordinate2D? = nil,
games: [UUID] = [],
games: [String] = [],
arrivalDate: Date = Date(),
departureDate: Date? = nil,
firstGameStart: Date? = nil