fix(data): populate stadium timezone in scrapers and CloudKit sync
Stadium timezones were always null because scrapers weren't passing the timezone from STADIUM_MAPPINGS to the Stadium constructor. This fix propagates timezone data through the entire pipeline: scrapers, CloudKit uploader, and Swift CloudKit model. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -672,6 +672,7 @@ class MLBScraper(BaseScraper):
|
||||
country=info.country,
|
||||
latitude=info.latitude,
|
||||
longitude=info.longitude,
|
||||
timezone=info.timezone,
|
||||
surface="grass", # Most MLB stadiums
|
||||
roof_type="open", # Most MLB stadiums
|
||||
)
|
||||
|
||||
@@ -387,6 +387,7 @@ class MLSScraper(BaseScraper):
|
||||
country=info.country,
|
||||
latitude=info.latitude,
|
||||
longitude=info.longitude,
|
||||
timezone=info.timezone,
|
||||
surface="grass",
|
||||
roof_type="open",
|
||||
)
|
||||
|
||||
@@ -648,6 +648,7 @@ class NBAScraper(BaseScraper):
|
||||
country=info.country,
|
||||
latitude=info.latitude,
|
||||
longitude=info.longitude,
|
||||
timezone=info.timezone,
|
||||
surface="hardwood",
|
||||
roof_type="dome",
|
||||
)
|
||||
|
||||
@@ -566,6 +566,7 @@ class NFLScraper(BaseScraper):
|
||||
country=info.country,
|
||||
latitude=info.latitude,
|
||||
longitude=info.longitude,
|
||||
timezone=info.timezone,
|
||||
surface="turf", # Many NFL stadiums
|
||||
roof_type="open", # Most outdoor
|
||||
)
|
||||
|
||||
@@ -644,6 +644,7 @@ class NHLScraper(BaseScraper):
|
||||
country=info.country,
|
||||
latitude=info.latitude,
|
||||
longitude=info.longitude,
|
||||
timezone=info.timezone,
|
||||
surface="ice",
|
||||
roof_type="dome",
|
||||
)
|
||||
|
||||
@@ -361,6 +361,7 @@ class NWSLScraper(BaseScraper):
|
||||
country=info.country,
|
||||
latitude=info.latitude,
|
||||
longitude=info.longitude,
|
||||
timezone=info.timezone,
|
||||
surface="grass",
|
||||
roof_type="open",
|
||||
)
|
||||
|
||||
@@ -362,6 +362,7 @@ class WNBAScraper(BaseScraper):
|
||||
country=info.country,
|
||||
latitude=info.latitude,
|
||||
longitude=info.longitude,
|
||||
timezone=info.timezone,
|
||||
surface="hardwood",
|
||||
roof_type="dome",
|
||||
)
|
||||
|
||||
@@ -545,6 +545,7 @@ class RecordDiffer:
|
||||
- yearOpened: Year opened as int
|
||||
- imageURL: URL string for stadium image
|
||||
- sport: Sport code uppercase (e.g., "MLB")
|
||||
- timezoneIdentifier: IANA timezone (e.g., "America/New_York")
|
||||
"""
|
||||
return CloudKitRecord(
|
||||
record_name=stadium.id,
|
||||
@@ -564,6 +565,7 @@ class RecordDiffer:
|
||||
"capacity": stadium.capacity,
|
||||
"yearOpened": stadium.opened_year,
|
||||
"imageURL": stadium.image_url,
|
||||
"timezoneIdentifier": stadium.timezone,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ struct CKStadium {
|
||||
static let yearOpenedKey = "yearOpened"
|
||||
static let imageURLKey = "imageURL"
|
||||
static let sportKey = "sport"
|
||||
static let timezoneIdentifierKey = "timezoneIdentifier"
|
||||
|
||||
let record: CKRecord
|
||||
|
||||
@@ -160,6 +161,7 @@ struct CKStadium {
|
||||
let imageURL = (record[CKStadium.imageURLKey] as? String).flatMap { URL(string: $0) }
|
||||
let sportRaw = record[CKStadium.sportKey] as? String ?? "MLB"
|
||||
let sport = Sport(rawValue: sportRaw) ?? .mlb
|
||||
let timezoneIdentifier = record[CKStadium.timezoneIdentifierKey] as? String
|
||||
|
||||
return Stadium(
|
||||
id: id,
|
||||
@@ -171,7 +173,8 @@ struct CKStadium {
|
||||
capacity: capacity,
|
||||
sport: sport,
|
||||
yearOpened: record[CKStadium.yearOpenedKey] as? Int,
|
||||
imageURL: imageURL
|
||||
imageURL: imageURL,
|
||||
timeZoneIdentifier: timezoneIdentifier
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user