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:
@@ -20,7 +20,7 @@ struct DuplicateGameIdTests {
|
||||
|
||||
private func makeStadium(sport: Sport = .mlb) -> Stadium {
|
||||
Stadium(
|
||||
id: UUID(),
|
||||
id: "stadium_test_\(UUID().uuidString)",
|
||||
name: "Test Stadium",
|
||||
city: "Test City",
|
||||
state: "TS",
|
||||
@@ -31,9 +31,9 @@ struct DuplicateGameIdTests {
|
||||
)
|
||||
}
|
||||
|
||||
private func makeTeam(sport: Sport = .mlb, stadiumId: UUID) -> Team {
|
||||
private func makeTeam(sport: Sport = .mlb, stadiumId: String) -> Team {
|
||||
Team(
|
||||
id: UUID(),
|
||||
id: "team_test_\(UUID().uuidString)",
|
||||
name: "Test Team",
|
||||
abbreviation: "TST",
|
||||
sport: sport,
|
||||
@@ -42,7 +42,7 @@ struct DuplicateGameIdTests {
|
||||
)
|
||||
}
|
||||
|
||||
private func makeGame(id: UUID, homeTeamId: UUID, awayTeamId: UUID, stadiumId: UUID, dateTime: Date) -> Game {
|
||||
private func makeGame(id: String, homeTeamId: String, awayTeamId: String, stadiumId: String, dateTime: Date) -> Game {
|
||||
Game(
|
||||
id: id,
|
||||
homeTeamId: homeTeamId,
|
||||
@@ -59,16 +59,16 @@ struct DuplicateGameIdTests {
|
||||
@Test("Duplicate games are deduplicated at load time")
|
||||
func gamesArray_DeduplicatesById() {
|
||||
// Simulate the deduplication logic used in StubDataProvider
|
||||
let gameId = UUID()
|
||||
let gameId = "game_test_\(UUID().uuidString)"
|
||||
let dateTime = Date()
|
||||
|
||||
let game1 = makeGame(id: gameId, homeTeamId: UUID(), awayTeamId: UUID(), stadiumId: UUID(), dateTime: dateTime)
|
||||
let game2 = makeGame(id: gameId, homeTeamId: UUID(), awayTeamId: UUID(), stadiumId: UUID(), dateTime: dateTime.addingTimeInterval(3600))
|
||||
let game1 = makeGame(id: gameId, homeTeamId: "team_home_\(UUID().uuidString)", awayTeamId: "team_away_\(UUID().uuidString)", stadiumId: "stadium_test_\(UUID().uuidString)", dateTime: dateTime)
|
||||
let game2 = makeGame(id: gameId, homeTeamId: "team_home_\(UUID().uuidString)", awayTeamId: "team_away_\(UUID().uuidString)", stadiumId: "stadium_test_\(UUID().uuidString)", dateTime: dateTime.addingTimeInterval(3600))
|
||||
|
||||
let games = [game1, game2]
|
||||
|
||||
// Deduplication logic from StubDataProvider
|
||||
var seenIds = Set<UUID>()
|
||||
var seenIds = Set<String>()
|
||||
let uniqueGames = games.filter { game in
|
||||
if seenIds.contains(game.id) {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user