From 7d39e94aeb458d4e019d14b9a6decd435e323286 Mon Sep 17 00:00:00 2001 From: Raz Date: Tue, 4 Mar 2025 18:06:54 +0100 Subject: [PATCH] v1.1.20 --- PadelClub.xcodeproj/project.pbxproj | 8 ++++---- PadelClub/Data/TeamRegistration.swift | 3 ++- PadelClub/Data/Tournament.swift | 3 +-- PadelClub/Extensions/Sequence+Extensions.swift | 18 ++++++++---------- PadelClub/Utils/Network/NetworkManager.swift | 4 ++-- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index 398cc2b..f360c27 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -3318,7 +3318,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; @@ -3344,7 +3344,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.1.19; + MARKETING_VERSION = 1.1.20; PRODUCT_BUNDLE_IDENTIFIER = app.padelclub; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -3364,7 +3364,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; @@ -3389,7 +3389,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.1.19; + MARKETING_VERSION = 1.1.20; PRODUCT_BUNDLE_IDENTIFIER = app.padelclub; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/PadelClub/Data/TeamRegistration.swift b/PadelClub/Data/TeamRegistration.swift index 8a9066e..c6d9d80 100644 --- a/PadelClub/Data/TeamRegistration.swift +++ b/PadelClub/Data/TeamRegistration.swift @@ -533,7 +533,8 @@ final class TeamRegistration: ModelObject, Storable { func setWeight(from players: [PlayerRegistration], inTournamentCategory tournamentCategory: TournamentCategory) { let significantPlayerCount = significantPlayerCount() - weight = (players.prefix(significantPlayerCount).map { $0.computedRank } + missingPlayerType(inTournamentCategory: tournamentCategory).map { unrankValue(for: $0 == 1 ? true : false ) }).prefix(significantPlayerCount).reduce(0,+) + let sortedPlayers = players.sorted(by: \.computedRank, order: .ascending) + weight = (sortedPlayers.prefix(significantPlayerCount).map { $0.computedRank } + missingPlayerType(inTournamentCategory: tournamentCategory).map { unrankValue(for: $0 == 1 ? true : false ) }).prefix(significantPlayerCount).reduce(0,+) } func significantPlayerCount() -> Int { diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index a763ac7..57c449f 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -1509,8 +1509,7 @@ defer { teams.forEach { team in let players = team.unsortedPlayers() players.forEach { $0.setComputedRank(in: self) } - let sortedPlayers = players.sorted(by: \.computedRank, order: .ascending) - team.setWeight(from: sortedPlayers, inTournamentCategory: tournamentCategory) + team.setWeight(from: players, inTournamentCategory: tournamentCategory) do { try self.tournamentStore.playerRegistrations.addOrUpdate(contentOfs: players) } catch { diff --git a/PadelClub/Extensions/Sequence+Extensions.swift b/PadelClub/Extensions/Sequence+Extensions.swift index e95ba3a..9d21624 100644 --- a/PadelClub/Extensions/Sequence+Extensions.swift +++ b/PadelClub/Extensions/Sequence+Extensions.swift @@ -32,34 +32,32 @@ extension Sequence { func concurrentForEach( _ operation: @escaping (Element) async throws -> Void ) async throws { - // A task group automatically waits for all of its - // sub-tasks to complete, while also performing those - // tasks in parallel: try await withThrowingTaskGroup(of: Void.self) { group in + // First, create all tasks for element in self { group.addTask { try await operation(element) } - - for try await _ in group {} } + + // Then wait for all tasks to complete + for try await _ in group {} } } func concurrentForEach( _ operation: @escaping (Element) async -> Void ) async { - // A task group automatically waits for all of its - // sub-tasks to complete, while also performing those - // tasks in parallel: await withTaskGroup(of: Void.self) { group in + // First, add all tasks for element in self { group.addTask { await operation(element) } - - for await _ in group {} } + + // Then wait for all tasks to complete + for await _ in group {} } } diff --git a/PadelClub/Utils/Network/NetworkManager.swift b/PadelClub/Utils/Network/NetworkManager.swift index 6a7a7e6..0f32b96 100644 --- a/PadelClub/Utils/Network/NetworkManager.swift +++ b/PadelClub/Utils/Network/NetworkManager.swift @@ -51,9 +51,9 @@ class NetworkManager { let documentsUrl: URL = SourceFileManager.shared.rankingSourceDirectory let destinationFileUrl = documentsUrl.appendingPathComponent("\(dateString)") - let fileURL = URL(string: "https://xlr.alwaysdata.net/static/rankings/\(dateString)") + let fileURL = URLs.main.extend(path: "static/rankings/\(dateString)") - var request = URLRequest(url:fileURL!) + var request = URLRequest(url:fileURL) request.addValue("attachment;filename=\(dateString)", forHTTPHeaderField:"Content-Disposition") if FileManager.default.fileExists(atPath: destinationFileUrl.path()), let modificationDate = destinationFileUrl.creationDate() { request.addValue(formatDateForHTTPHeader(modificationDate), forHTTPHeaderField: "If-Modified-Since")