Skip to content

Commit

Permalink
Updating MotoTiming overview response model
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-ruzicka committed Mar 19, 2023
1 parent 7fb7d89 commit dc5b632
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private extension String {
let countryName = locale
.displayName(forKey: NSLocale.Key.countryCode, value: code)?
.sanitizedCountryName ?? ""
if countryName.lowercased().contains(self.lowercased()) {
if countryName.lowercased() == sanitizedCountryName.lowercased() {
return code
}
}
Expand All @@ -65,6 +65,8 @@ private extension String {
return "USA"
case "United Arab Emirates":
return "UAE"
case "UK":
return "United Kingdom"
default:
return self
}
Expand All @@ -87,6 +89,8 @@ private extension ErgastEventResponseModel.MRData.RaceTable.Race {
mapName = "United States"
case "Yas Marina Circuit":
mapName = "Abu Dhabi"
case "Las Vegas Strip Street Circuit":
mapName = "Las Vegas carbon"
default:
break
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ private extension MotoTimingEventResponseModel {
return .init(latitude: 2.7603410090567575, longitude: 101.73281683732247)
case "Circuit Ricardo Tormo":
return .init(latitude: 39.48816050658184, longitude: 0.6292142246673847)
case "Sokol International Racetrack":
return .init(latitude: 43.584038286041036, longitude: 76.56895699535758)
case "Buddh International Circuit":
return .init(latitude: 28.350607264370716, longitude: 77.53538148192355)
default:
NonFatalHandler.log(.missingValue(valueType: "location",
key: circuit,
Expand Down Expand Up @@ -145,6 +149,10 @@ private extension MotoTimingEventResponseModel {
mapName = "787801514"
case "Circuit Ricardo Tormo":
mapName = "659572185"
case "Sokol International Racetrack":
mapName = "1363336181"
case "Buddh International Circuit":
mapName = "886244889"
default:
NonFatalHandler.log(.missingValue(valueType: "trackMapUrl",
key: circuit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@

struct MotoTimingEventOverviewResponseModel: Decodable {

let name: String
let start_date: String
let end_date: String
let test: Int
let calendar: [Event]

struct Event: Decodable {

let name: String
let start_date: String
let end_date: String
let test: Int
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ extension Session {
private extension SessionType {

init?(from motoTimingShortName: String) {
if motoTimingShortName.starts(with: "FP"),
let number = Int(motoTimingShortName.replacingOccurrences(of: "FP", with: "")) {
if motoTimingShortName.starts(with: "P"),
let number = Int(motoTimingShortName.replacingOccurrences(of: "P", with: "")) {
self = .practice(number: number)
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ extension MotoGPEventsRepositoryImpl: EventsRepository {
private extension MotoGPEventsRepositoryImpl {

func fetchComingEventNames() async throws -> [String] {
let overviews: [MotoTimingEventOverviewResponseModel] = try await networking
let response: MotoTimingEventOverviewResponseModel = try await networking
.request(MotoTimingRequestSpec.getMotogpThisYearsEvents)
let currentDate = Date()
return overviews
return response.calendar
.filter { $0.test == 0 }
.filter { Date(string: $0.end_date)?.addingTimeInterval(24 * 60 * 60) ?? currentDate > currentDate }
.sorted(by: { Date(string: $0.start_date) ?? currentDate < Date(string: $1.start_date) ?? currentDate })
Expand Down
8 changes: 4 additions & 4 deletions RaceWeather.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = accent;
CODE_SIGN_ENTITLEMENTS = Resources/RaceWeather.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 8868RWK6YB;
Expand All @@ -389,7 +389,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.2;
MARKETING_VERSION = 1.0.3;
PRODUCT_BUNDLE_IDENTIFIER = io.ruzicka.RaceWeather;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -405,7 +405,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = accent;
CODE_SIGN_ENTITLEMENTS = Resources/RaceWeather.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 8868RWK6YB;
ENABLE_PREVIEWS = YES;
Expand All @@ -421,7 +421,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.2;
MARKETING_VERSION = 1.0.3;
PRODUCT_BUNDLE_IDENTIFIER = io.ruzicka.RaceWeather;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down

0 comments on commit dc5b632

Please sign in to comment.