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

@@ -926,7 +926,7 @@ struct TripCreationView: View {
)
}
private func buildGamesDictionary() -> [UUID: RichGame] {
private func buildGamesDictionary() -> [String: RichGame] {
viewModel.availableGames.reduce(into: [:]) { $0[$1.id] = $1 }
}
}
@@ -949,16 +949,16 @@ extension TripCreationViewModel.ViewState {
struct GamePickerSheet: View {
let games: [RichGame]
@Binding var selectedIds: Set<UUID>
@Binding var selectedIds: Set<String>
@Environment(\.dismiss) private var dismiss
@Environment(\.colorScheme) private var colorScheme
@State private var expandedSports: Set<Sport> = []
@State private var expandedTeams: Set<UUID> = []
@State private var expandedTeams: Set<String> = []
// Group games by Sport Team (home team only to avoid duplicates)
private var gamesBySport: [Sport: [TeamWithGames]] {
var result: [Sport: [UUID: TeamWithGames]] = [:]
var result: [Sport: [String: TeamWithGames]] = [:]
for game in games {
let sport = game.game.sport
@@ -1063,9 +1063,9 @@ struct GamePickerSheet: View {
struct SportSection: View {
let sport: Sport
let teams: [TeamWithGames]
@Binding var selectedIds: Set<UUID>
@Binding var selectedIds: Set<String>
@Binding var expandedSports: Set<Sport>
@Binding var expandedTeams: Set<UUID>
@Binding var expandedTeams: Set<String>
let selectedCount: Int
@Environment(\.colorScheme) private var colorScheme
@@ -1146,8 +1146,8 @@ struct SportSection: View {
struct TeamSection: View {
let teamData: TeamWithGames
@Binding var selectedIds: Set<UUID>
@Binding var expandedTeams: Set<UUID>
@Binding var selectedIds: Set<String>
@Binding var expandedTeams: Set<String>
@Environment(\.colorScheme) private var colorScheme
@@ -1310,7 +1310,7 @@ struct TeamWithGames: Identifiable {
let sport: Sport
var games: [RichGame]
var id: UUID { team.id }
var id: String { team.id }
var sortedGames: [RichGame] {
games.sorted { $0.game.dateTime < $1.game.dateTime }
@@ -1504,7 +1504,7 @@ enum CitiesFilter: Int, CaseIterable, Identifiable {
struct TripOptionsView: View {
let options: [ItineraryOption]
let games: [UUID: RichGame]
let games: [String: RichGame]
let preferences: TripPreferences?
let convertToTrip: (ItineraryOption) -> Trip
@@ -1774,7 +1774,7 @@ struct TripOptionsView: View {
struct TripOptionCard: View {
let option: ItineraryOption
let games: [UUID: RichGame]
let games: [String: RichGame]
let onSelect: () -> Void
@Environment(\.colorScheme) private var colorScheme
@@ -2393,7 +2393,7 @@ struct DayCell: View {
// MARK: - Team Picker Sheet
struct TeamPickerSheet: View {
@Binding var selectedTeamId: UUID?
@Binding var selectedTeamId: String?
let teamsBySport: [Sport: [Team]]
@Environment(\.dismiss) private var dismiss