From 64a324608dfd959f395809d59f472896a7f52c7b Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Tue, 10 Jun 2025 08:56:50 +0200 Subject: [PATCH 1/2] fix issue with planned date --- PadelClubData/Data/GroupStage.swift | 4 +--- PadelClubData/Data/Match.swift | 6 +----- PadelClubData/Data/Round.swift | 4 +--- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/PadelClubData/Data/GroupStage.swift b/PadelClubData/Data/GroupStage.swift index 23a597d..6a61555 100644 --- a/PadelClubData/Data/GroupStage.swift +++ b/PadelClubData/Data/GroupStage.swift @@ -29,9 +29,7 @@ final public class GroupStage: BaseGroupStage, SideStorable { // MARK: - DidSet public override func didSetStartDate() { - if self.tournamentValue()?.hasStarted() == false { - plannedStartDate = startDate - } + plannedStartDate = startDate } // MARK: - Computed dependencies diff --git a/PadelClubData/Data/Match.swift b/PadelClubData/Data/Match.swift index 3023515..da11675 100644 --- a/PadelClubData/Data/Match.swift +++ b/PadelClubData/Data/Match.swift @@ -28,11 +28,7 @@ final public class Match: BaseMatch, SideStorable { if hasStarted() { return } - if self.roundValue()?.tournamentObject()?.hasStarted() == false { - plannedStartDate = startDate - } else if self.groupStageValue()?.tournamentObject()?.hasStarted() == false { - plannedStartDate = startDate - } + plannedStartDate = startDate } // MARK: - diff --git a/PadelClubData/Data/Round.swift b/PadelClubData/Data/Round.swift index e00dfed..9d5f644 100644 --- a/PadelClubData/Data/Round.swift +++ b/PadelClubData/Data/Round.swift @@ -24,9 +24,7 @@ final public class Round: BaseRound, SideStorable { // MARK: - DidSet public override func didSetStartDate() { - if self.tournamentValue()?.hasStarted() == false { - plannedStartDate = startDate - } + plannedStartDate = startDate } // MARK: - Computed dependencies From f7cc4ffa877017836c6140cdf3b4490479bb3666 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Thu, 12 Jun 2025 08:02:40 +0200 Subject: [PATCH 2/2] fix some import stuff add event contact sharing --- PadelClubData/Data/Event.swift | 36 +++++++++++++++++++++ PadelClubData/Data/GroupStage.swift | 4 +++ PadelClubData/Data/PlayerRegistration.swift | 19 ++++++++--- PadelClubData/Data/TeamRegistration.swift | 2 +- PadelClubData/Data/Tournament.swift | 6 ++++ 5 files changed, 61 insertions(+), 6 deletions(-) diff --git a/PadelClubData/Data/Event.swift b/PadelClubData/Data/Event.swift index 29f3fc6..94767f0 100644 --- a/PadelClubData/Data/Event.swift +++ b/PadelClubData/Data/Event.swift @@ -156,6 +156,42 @@ final public class Event: BaseEvent { return "Du \(startDay) \(startMonthYear) au \(endDay) \(endMonthYear)" } } + + public func tournamentInformation() -> String? { + confirmedTournaments().first?.information + } + + public func eventLinksPasteData() -> String { + let tournaments = self.confirmedTournaments() + var link = [String?]() + link.append(eventTitle()) + + link.append(tournamentInformation()) + + if let url = shareURL() { + var tournamentLink = [String]() + tournamentLink.append("Lien de l'événement") + tournamentLink.append(url.absoluteString) + let eventLink = tournamentLink.joined(separator: "\n") + link.append(eventLink) + } + + link.append("Retrouvez toutes les infos en suivant le\(tournaments.count.pluralSuffix) lien\(tournaments.count.pluralSuffix) ci-dessous :") + + link.append(tournaments.compactMap({ tournament in + if let url = tournament.shareURL(.info) { + var tournamentLink = [String]() + tournamentLink.append(tournament.tournamentTitle(.title)) + tournamentLink.append(url.absoluteString) + return tournamentLink.joined(separator: "\n") + } else { + return nil + } + }).joined(separator: "\n\n")) + + return link.compactMap({ $0 }).joined(separator: "\n\n") + } + func insertOnServer() throws { DataStore.shared.events.writeChangeAndInsertOnServer(instance: self) diff --git a/PadelClubData/Data/GroupStage.swift b/PadelClubData/Data/GroupStage.swift index 6a61555..ed60c1d 100644 --- a/PadelClubData/Data/GroupStage.swift +++ b/PadelClubData/Data/GroupStage.swift @@ -537,6 +537,10 @@ final public class GroupStage: BaseGroupStage, SideStorable { public func clearScoreCache() { scoreCache.removeAll() } + + var computedStartDateForSorting: Date { + startDate ?? computedStartDate() ?? .distantFuture + } // public func teams(_ sortedByScore: Bool = false, scores: [TeamGroupStageScore]? = nil) -> [TeamRegistration] { // if sortedByScore { diff --git a/PadelClubData/Data/PlayerRegistration.swift b/PadelClubData/Data/PlayerRegistration.swift index afc6c4d..880e9c6 100644 --- a/PadelClubData/Data/PlayerRegistration.swift +++ b/PadelClubData/Data/PlayerRegistration.swift @@ -89,8 +89,14 @@ final public class PlayerRegistration: BasePlayerRegistration, SideStorable { } public func isSameAs(_ player: PlayerRegistration) -> Bool { - firstName.trimmedMultiline.canonicalVersion.localizedCaseInsensitiveCompare(player.firstName.trimmedMultiline.canonicalVersion) == .orderedSame && - lastName.trimmedMultiline.canonicalVersion.localizedCaseInsensitiveCompare(player.lastName.trimmedMultiline.canonicalVersion) == .orderedSame + if let licenceId, let playerLicenceId = player.licenceId { + let result = licenceId.strippedLicense == playerLicenceId.strippedLicense + if result { + return result + } + } + return firstName.trimmedMultiline.canonicalVersion.localizedCaseInsensitiveCompare(player.firstName.trimmedMultiline.canonicalVersion) == .orderedSame && + lastName.trimmedMultiline.canonicalVersion.localizedCaseInsensitiveCompare(player.lastName.trimmedMultiline.canonicalVersion) == .orderedSame } public func tournament() -> Tournament? { @@ -158,11 +164,14 @@ final public class PlayerRegistration: BasePlayerRegistration, SideStorable { } } - public func setComputedRank(in tournament: Tournament) { - let currentRank = rank ?? tournament.unrankValue(for: isMalePlayer()) ?? 90_000 + public func setComputedRank(in tournament: Tournament) { + let maleUnranked = tournament.unrankValue(for: isMalePlayer()) ?? 90_415 + let femaleUnranked = tournament.unrankValue(for: false) ?? 0 + let currentRank = rank ?? maleUnranked switch tournament.tournamentCategory { case .men: - computedRank = isMalePlayer() ? currentRank : currentRank + PlayerRegistration.addon(for: currentRank, manMax: tournament.maleUnrankedValue ?? 0, womanMax: tournament.femaleUnrankedValue ?? 0) + let addon = PlayerRegistration.addon(for: currentRank, manMax: maleUnranked, womanMax: femaleUnranked) + computedRank = isMalePlayer() ? currentRank : currentRank + addon default: computedRank = currentRank } diff --git a/PadelClubData/Data/TeamRegistration.swift b/PadelClubData/Data/TeamRegistration.swift index f07fcb4..441d0ec 100644 --- a/PadelClubData/Data/TeamRegistration.swift +++ b/PadelClubData/Data/TeamRegistration.swift @@ -542,7 +542,7 @@ final public class TeamRegistration: BaseTeamRegistration, SideStorable { } public func unrankValue(for malePlayer: Bool) -> Int { - return tournamentObject()?.unrankValue(for: malePlayer) ?? 90_000 + return tournamentObject()?.unrankValue(for: malePlayer) ?? 90_415 } public func groupStageObject() -> GroupStage? { diff --git a/PadelClubData/Data/Tournament.swift b/PadelClubData/Data/Tournament.swift index 045bf79..80e3fd5 100644 --- a/PadelClubData/Data/Tournament.swift +++ b/PadelClubData/Data/Tournament.swift @@ -616,6 +616,9 @@ defer { return waitingListTeams(in: teams, includingWalkOuts: false) } + public func allTeamsWithoutWalkOut() -> [TeamRegistration] { + return unsortedTeams().filter({ !$0.walkOut }) + } public func selectedSortedTeams() -> [TeamRegistration] { #if _DEBUG_TIME //DEBUGING TIME @@ -2309,6 +2312,9 @@ defer { return matchCountPerDay } + public func groupStageStartDate() -> Date? { + groupStages().sorted(by: \.computedStartDateForSorting).first?.startDate + } // MARK: -