From f67f283b5eaf66c4ac3ebb54b1bb17172c54df2d Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Fri, 5 Sep 2025 14:05:40 +0200 Subject: [PATCH 1/4] fix editscoreview yes add menu to change name --- PadelClubData/Data/TeamRegistration.swift | 2 +- PadelClubData/Data/Tournament.swift | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/PadelClubData/Data/TeamRegistration.swift b/PadelClubData/Data/TeamRegistration.swift index 865dfaf..cb3ef5c 100644 --- a/PadelClubData/Data/TeamRegistration.swift +++ b/PadelClubData/Data/TeamRegistration.swift @@ -256,7 +256,7 @@ final public class TeamRegistration: BaseTeamRegistration, SideStorable { public func teamLabel( _ displayStyle: DisplayStyle = .wide, twoLines: Bool = false, separator: String = "&" ) -> String { - if let name { return name } + if let name, name.isEmpty == false { return name } return players().map { $0.playerLabel(displayStyle) }.joined( separator: twoLines ? "\n" : " \(separator) ") } diff --git a/PadelClubData/Data/Tournament.swift b/PadelClubData/Data/Tournament.swift index 0fab86a..4d328c2 100644 --- a/PadelClubData/Data/Tournament.swift +++ b/PadelClubData/Data/Tournament.swift @@ -345,6 +345,7 @@ defer { public func availableSeedOpponentSpot(inRoundIndex roundIndex: Int) -> [Match] { return getRound(atRoundIndex: roundIndex)?.playedMatches().filter { $0.hasSpaceLeft() } ?? [] } + public func availableSeedGroups(includeAll: Bool = false) -> [SeedInterval] { let seeds = seeds() var availableSeedGroup = Set() @@ -362,6 +363,24 @@ defer { return availableSeedGroup.sorted(by: <) } + public func generateSeedGroups(base: Int, teamCount: Int) -> [SeedInterval] { + let start = base + 1 + let root = SeedInterval(first: start, last: start + teamCount - 1) + var groups: [SeedInterval] = [] + + func split(interval: SeedInterval) { + groups.append(interval) + if let chunks = interval.chunks() { + for chunk in chunks { + split(interval: chunk) + } + } + } + + split(interval: root) + return groups.sorted(by: <) + } + public func chunksBy(in chunks: [SeedInterval], availableSeedGroup: inout Set) { chunks.forEach { chunk in availableSeedGroup.insert(chunk) From 59642d1aca57b992b997d1cf3a4416e1b2f58969 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Mon, 15 Sep 2025 10:51:02 +0200 Subject: [PATCH 2/4] fix a smart planner issue --- PadelClubData/Data/MatchScheduler.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/PadelClubData/Data/MatchScheduler.swift b/PadelClubData/Data/MatchScheduler.swift index 5f16a7d..39ed5de 100644 --- a/PadelClubData/Data/MatchScheduler.swift +++ b/PadelClubData/Data/MatchScheduler.swift @@ -838,8 +838,10 @@ final public class MatchScheduler: BaseMatchScheduler, SideStorable { } - if tournament.dayDuration > 1 && (lastDate.timeOfDay == .evening || lastDate.timeOfDay == .night || errorFormat) { - bracketStartDate = lastDate.tomorrowAtNine + if tournament.dayDuration > 1 && (lastDate.timeOfDay == .evening || lastDate.timeOfDay == .night || errorFormat) { + if tournament.groupStageCount > 0 { + bracketStartDate = lastDate.tomorrowAtNine + } } return updateBracketSchedule(tournament: tournament, fromRoundId: nil, fromMatchId: nil, startDate: bracketStartDate) From 9ed8e56c2ec0520d12347dbb09d50f3b4aebddda Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Wed, 17 Sep 2025 11:12:56 +0200 Subject: [PATCH 3/4] fix issue with field setup add a way to set price on all tournaments of a month fix the tournament creation not using the most used price fix issue in team detail view regarding registratoin date modification --- PadelClubData/Data/Tournament.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/PadelClubData/Data/Tournament.swift b/PadelClubData/Data/Tournament.swift index 4d328c2..9c16560 100644 --- a/PadelClubData/Data/Tournament.swift +++ b/PadelClubData/Data/Tournament.swift @@ -1682,12 +1682,14 @@ defer { } public func initSettings(templateTournament: Tournament?, overrideTeamCount: Bool = true) { + courtCount = eventObject()?.clubObject()?.courtCount ?? 2 setupDefaultPrivateSettings(templateTournament: templateTournament) setupUmpireSettings(defaultTournament: nil) //default is not template, default is for event sharing settings if let templateTournament { setupRegistrationSettings(templateTournament: templateTournament, overrideTeamCount: overrideTeamCount) } setupFederalSettings() + customizeUsingPreferences() } public func setupFederalSettings() { @@ -1703,6 +1705,23 @@ defer { } } + public func customizeUsingPreferences() { + guard let lastTournamentWithSameBuild = DataStore.shared.tournaments.filter({ tournament in + tournament.tournamentLevel == self.tournamentLevel + && tournament.tournamentCategory == self.tournamentCategory + && tournament.federalTournamentAge == self.federalTournamentAge + && tournament.hasEnded() == true + && tournament.isCanceled == false + && tournament.isDeleted == false + }).sorted(by: \.endDate!, order: .descending).first else { + return + } + + self.entryFee = lastTournamentWithSameBuild.entryFee + self.clubMemberFeeDeduction = lastTournamentWithSameBuild.clubMemberFeeDeduction + } + + public func deadline(for type: TournamentDeadlineType) -> Date? { guard [.p500, .p1000, .p1500, .p2000].contains(tournamentLevel) else { return nil } From e3b3c6456cbf7722d6e9a714229f1acf46676183 Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 17 Sep 2025 15:39:18 +0200 Subject: [PATCH 4/4] minor improvements to Guard --- PadelClubData/Subscriptions/Guard.swift | 45 +++++++++++++++++++------ 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/PadelClubData/Subscriptions/Guard.swift b/PadelClubData/Subscriptions/Guard.swift index aa77c06..2ff17e7 100644 --- a/PadelClubData/Subscriptions/Guard.swift +++ b/PadelClubData/Subscriptions/Guard.swift @@ -30,11 +30,7 @@ import Combine self.updateListenerTask = self.listenForTransactions() Task { - do { - try await self.refreshPurchasedAppleProducts() - } catch { - Logger.error(error) - } + await self.refreshPurchases() Logger.log("plan = \(String(describing: currentBestPurchase?.productId))") } @@ -66,19 +62,46 @@ import Combine return productIds } - public func refreshPurchasedAppleProducts() async throws { + public func refreshPurchases() async { + await _refreshUnfinishedTransactions() + await _refreshPurchasedAppleProducts() + } + + fileprivate func _refreshPurchasedAppleProducts() async { // Iterate through the user's purchased products. for await verificationResult in Transaction.currentEntitlements { - let transaction = try await self.processTransactionResult(verificationResult) - print("processs product id = \(transaction.productID)") - DispatchQueue.main.async { - NotificationCenter.default.post(name: Notification.Name.StoreEventHappened, object: nil) + do { + let transaction = try await self.processTransactionResult(verificationResult) + print("processs product id = \(transaction.productID)") + DispatchQueue.main.async { + NotificationCenter.default.post(name: Notification.Name.StoreEventHappened, object: nil) + } + await transaction.finish() + } catch { + Logger.error(error) } - await transaction.finish() } } + public func _refreshUnfinishedTransactions() async { + + // Iterate through the user's purchased products. + for await verificationResult in Transaction.unfinished { + do { + let transaction = try await self.processTransactionResult(verificationResult) + print("processs product id = \(transaction.productID)") + DispatchQueue.main.async { + NotificationCenter.default.post(name: Notification.Name.StoreEventHappened, object: nil) + } + await transaction.finish() + } catch { + Logger.error(error) + } + } + } + + func listenForTransactions() -> Task { return Task(priority: .background) { //Iterate through any transactions which didn't come from a direct call to `purchase()`.