From c79bc191545d8a9f3f516ab14801c2a2babec570 Mon Sep 17 00:00:00 2001 From: Raz Date: Sat, 10 May 2025 10:37:09 +0200 Subject: [PATCH] add planned start date and prog setup options --- PadelClubData/Data/.DS_Store | Bin 6148 -> 6148 bytes PadelClubData/Data/Gen/BaseGroupStage.swift | 20 +++++++++++++++--- PadelClubData/Data/Gen/BaseMatch.swift | 22 +++++++++++++++++--- PadelClubData/Data/Gen/BaseRound.swift | 20 +++++++++++++++--- PadelClubData/Data/Gen/BaseTournament.swift | 16 +++++++++++++- PadelClubData/Data/Gen/GroupStage.json | 5 +++++ PadelClubData/Data/Gen/Match.json | 5 +++++ PadelClubData/Data/Gen/Round.json | 5 +++++ PadelClubData/Data/Gen/Tournament.json | 10 +++++++++ PadelClubData/Data/Tournament.swift | 9 ++++++++ PadelClubData/Utils/URLs.swift | 3 +++ 11 files changed, 105 insertions(+), 10 deletions(-) diff --git a/PadelClubData/Data/.DS_Store b/PadelClubData/Data/.DS_Store index 652a0a07005efd5a9d2b15d63064ff949273a4e4..8d4b30a0f497f7e1b5b31eed7fc9ca2632622b01 100644 GIT binary patch delta 305 zcmZoMXfc=|#>B`mu~3YagMono$Pkfb0y01VL^Col2rv{EB<18M0eL%;3MLjVuLnsm zGq^LPGUO$dBTMFF7MByppuyI%)FHRa;N;#yp&?F-e90a08oaLlY=u} zK%%PT-)7h;=iAi}bln}eGJ7$6%9zcWwf7g1yd`Bh=Ep@{Hi50O3008f=m1ONa4 delta 91 zcmZoMXfc=|#>AjHu~3+iaq=xjX=x?~2w((KKrFyel$VpAmk#1>{>UiCwuz~qaWgvy gKL=13P~bcBWPTAvPLS#ZAZD0s!lS%7Mq~vu05a [Relationship] { @@ -104,4 +118,4 @@ public class BaseGroupStage: SyncedModelObject, SyncedStorable { ] } -} \ No newline at end of file +} diff --git a/PadelClubData/Data/Gen/BaseMatch.swift b/PadelClubData/Data/Gen/BaseMatch.swift index 2665072..30bc175 100644 --- a/PadelClubData/Data/Gen/BaseMatch.swift +++ b/PadelClubData/Data/Gen/BaseMatch.swift @@ -15,7 +15,16 @@ public class BaseMatch: SyncedModelObject, SyncedStorable { public var id: String = Store.randomId() public var round: String? = nil public var groupStage: String? = nil - public var startDate: Date? = nil + public var startDate: Date? = nil { + didSet { + if self.roundValue()?.tournamentObject()?.hasStarted() == false { + plannedStartDate = startDate + } else if self.groupStageValue()?.tournamentObject()?.hasStarted() == false { + plannedStartDate = startDate + } + } + } + public var endDate: Date? = nil public var index: Int = 0 public var format: MatchFormat? = nil @@ -26,6 +35,7 @@ public class BaseMatch: SyncedModelObject, SyncedStorable { public var disabled: Bool = false public var courtIndex: Int? = nil public var confirmed: Bool = false + public var plannedStartDate: Date? = nil public init( id: String = Store.randomId(), @@ -41,7 +51,8 @@ public class BaseMatch: SyncedModelObject, SyncedStorable { name: String? = nil, disabled: Bool = false, courtIndex: Int? = nil, - confirmed: Bool = false + confirmed: Bool = false, + plannedStartDate: Date? = nil ) { super.init() self.id = id @@ -58,6 +69,7 @@ public class BaseMatch: SyncedModelObject, SyncedStorable { self.disabled = disabled self.courtIndex = courtIndex self.confirmed = confirmed + self.plannedStartDate = plannedStartDate } required public override init() { super.init() @@ -78,6 +90,7 @@ public class BaseMatch: SyncedModelObject, SyncedStorable { case _disabled = "disabled" case _courtIndex = "courtIndex" case _confirmed = "confirmed" + case _plannedStartDate = "plannedStartDate" } required init(from decoder: Decoder) throws { @@ -96,6 +109,7 @@ public class BaseMatch: SyncedModelObject, SyncedStorable { self.disabled = try container.decodeIfPresent(Bool.self, forKey: ._disabled) ?? false self.courtIndex = try container.decodeIfPresent(Int.self, forKey: ._courtIndex) ?? nil self.confirmed = try container.decodeIfPresent(Bool.self, forKey: ._confirmed) ?? false + self.plannedStartDate = try container.decodeIfPresent(Date.self, forKey: ._plannedStartDate) ?? nil try super.init(from: decoder) } @@ -115,6 +129,7 @@ public class BaseMatch: SyncedModelObject, SyncedStorable { try container.encode(self.disabled, forKey: ._disabled) try container.encode(self.courtIndex, forKey: ._courtIndex) try container.encode(self.confirmed, forKey: ._confirmed) + try container.encode(self.plannedStartDate, forKey: ._plannedStartDate) try super.encode(to: encoder) } @@ -144,6 +159,7 @@ public class BaseMatch: SyncedModelObject, SyncedStorable { self.disabled = match.disabled self.courtIndex = match.courtIndex self.confirmed = match.confirmed + self.plannedStartDate = match.plannedStartDate } public static func relationships() -> [Relationship] { @@ -153,4 +169,4 @@ public class BaseMatch: SyncedModelObject, SyncedStorable { ] } -} \ No newline at end of file +} diff --git a/PadelClubData/Data/Gen/BaseRound.swift b/PadelClubData/Data/Gen/BaseRound.swift index b06a950..ebcd5fe 100644 --- a/PadelClubData/Data/Gen/BaseRound.swift +++ b/PadelClubData/Data/Gen/BaseRound.swift @@ -17,9 +17,17 @@ public class BaseRound: SyncedModelObject, SyncedStorable { public var index: Int = 0 public var parent: String? = nil public var format: MatchFormat? = nil - public var startDate: Date? = nil + public var startDate: Date? = nil { + didSet { + if self.tournamentValue()?.hasStarted() == false { + plannedStartDate = startDate + } + } + } + public var groupStageLoserBracket: Bool = false public var loserBracketMode: LoserBracketMode = .automatic + public var plannedStartDate: Date? = nil public init( id: String = Store.randomId(), @@ -29,7 +37,8 @@ public class BaseRound: SyncedModelObject, SyncedStorable { format: MatchFormat? = nil, startDate: Date? = nil, groupStageLoserBracket: Bool = false, - loserBracketMode: LoserBracketMode = .automatic + loserBracketMode: LoserBracketMode = .automatic, + plannedStartDate: Date? = nil ) { super.init() self.id = id @@ -40,6 +49,7 @@ public class BaseRound: SyncedModelObject, SyncedStorable { self.startDate = startDate self.groupStageLoserBracket = groupStageLoserBracket self.loserBracketMode = loserBracketMode + self.plannedStartDate = plannedStartDate } required public override init() { super.init() @@ -54,6 +64,7 @@ public class BaseRound: SyncedModelObject, SyncedStorable { case _startDate = "startDate" case _groupStageLoserBracket = "groupStageLoserBracket" case _loserBracketMode = "loserBracketMode" + case _plannedStartDate = "plannedStartDate" } required init(from decoder: Decoder) throws { @@ -66,6 +77,7 @@ public class BaseRound: SyncedModelObject, SyncedStorable { self.startDate = try container.decodeIfPresent(Date.self, forKey: ._startDate) ?? nil self.groupStageLoserBracket = try container.decodeIfPresent(Bool.self, forKey: ._groupStageLoserBracket) ?? false self.loserBracketMode = try container.decodeIfPresent(LoserBracketMode.self, forKey: ._loserBracketMode) ?? .automatic + self.plannedStartDate = try container.decodeIfPresent(Date.self, forKey: ._plannedStartDate) ?? nil try super.init(from: decoder) } @@ -79,6 +91,7 @@ public class BaseRound: SyncedModelObject, SyncedStorable { try container.encode(self.startDate, forKey: ._startDate) try container.encode(self.groupStageLoserBracket, forKey: ._groupStageLoserBracket) try container.encode(self.loserBracketMode, forKey: ._loserBracketMode) + try container.encode(self.plannedStartDate, forKey: ._plannedStartDate) try super.encode(to: encoder) } @@ -96,6 +109,7 @@ public class BaseRound: SyncedModelObject, SyncedStorable { self.startDate = round.startDate self.groupStageLoserBracket = round.groupStageLoserBracket self.loserBracketMode = round.loserBracketMode + self.plannedStartDate = round.plannedStartDate } public static func relationships() -> [Relationship] { @@ -104,4 +118,4 @@ public class BaseRound: SyncedModelObject, SyncedStorable { ] } -} \ No newline at end of file +} diff --git a/PadelClubData/Data/Gen/BaseTournament.swift b/PadelClubData/Data/Gen/BaseTournament.swift index 68ea612..d837d1e 100644 --- a/PadelClubData/Data/Gen/BaseTournament.swift +++ b/PadelClubData/Data/Gen/BaseTournament.swift @@ -79,6 +79,8 @@ public class BaseTournament: SyncedModelObject, SyncedStorable { public var enableTimeToConfirm: Bool = false public var isCorporateTournament: Bool = false public var isTemplate: Bool = false + public var publishProg: Bool = false + public var showTeamsInProg: Bool = false public init( id: String = Store.randomId(), @@ -147,7 +149,9 @@ public class BaseTournament: SyncedModelObject, SyncedStorable { stripeAccountId: String? = nil, enableTimeToConfirm: Bool = false, isCorporateTournament: Bool = false, - isTemplate: Bool = false + isTemplate: Bool = false, + publishProg: Bool = false, + showTeamsInProg: Bool = false ) { super.init() self.id = id @@ -217,6 +221,8 @@ public class BaseTournament: SyncedModelObject, SyncedStorable { self.enableTimeToConfirm = enableTimeToConfirm self.isCorporateTournament = isCorporateTournament self.isTemplate = isTemplate + self.publishProg = publishProg + self.showTeamsInProg = showTeamsInProg } required public override init() { super.init() @@ -292,6 +298,8 @@ public class BaseTournament: SyncedModelObject, SyncedStorable { case _enableTimeToConfirm = "enableTimeToConfirm" case _isCorporateTournament = "isCorporateTournament" case _isTemplate = "isTemplate" + case _publishProg = "publishProg" + case _showTeamsInProg = "showTeamsInProg" } private static func _decodePayment(container: KeyedDecodingContainer) throws -> TournamentPayment? { @@ -430,6 +438,8 @@ public class BaseTournament: SyncedModelObject, SyncedStorable { self.enableTimeToConfirm = try container.decodeIfPresent(Bool.self, forKey: ._enableTimeToConfirm) ?? false self.isCorporateTournament = try container.decodeIfPresent(Bool.self, forKey: ._isCorporateTournament) ?? false self.isTemplate = try container.decodeIfPresent(Bool.self, forKey: ._isTemplate) ?? false + self.publishProg = try container.decodeIfPresent(Bool.self, forKey: ._publishProg) ?? false + self.showTeamsInProg = try container.decodeIfPresent(Bool.self, forKey: ._showTeamsInProg) ?? false try super.init(from: decoder) } @@ -502,6 +512,8 @@ public class BaseTournament: SyncedModelObject, SyncedStorable { try container.encode(self.enableTimeToConfirm, forKey: ._enableTimeToConfirm) try container.encode(self.isCorporateTournament, forKey: ._isCorporateTournament) try container.encode(self.isTemplate, forKey: ._isTemplate) + try container.encode(self.publishProg, forKey: ._publishProg) + try container.encode(self.showTeamsInProg, forKey: ._showTeamsInProg) try super.encode(to: encoder) } @@ -579,6 +591,8 @@ public class BaseTournament: SyncedModelObject, SyncedStorable { self.enableTimeToConfirm = tournament.enableTimeToConfirm self.isCorporateTournament = tournament.isCorporateTournament self.isTemplate = tournament.isTemplate + self.publishProg = tournament.publishProg + self.showTeamsInProg = tournament.showTeamsInProg } public static func relationships() -> [Relationship] { diff --git a/PadelClubData/Data/Gen/GroupStage.json b/PadelClubData/Data/Gen/GroupStage.json index ecfdad5..ef293b3 100644 --- a/PadelClubData/Data/Gen/GroupStage.json +++ b/PadelClubData/Data/Gen/GroupStage.json @@ -45,6 +45,11 @@ "name": "step", "type": "Int", "defaultValue": "0" + }, + { + "name": "plannedStartDate", + "type": "Date", + "optional": true } ], "tokenExemptedMethods": [] diff --git a/PadelClubData/Data/Gen/Match.json b/PadelClubData/Data/Gen/Match.json index 913014c..fbe77b4 100644 --- a/PadelClubData/Data/Gen/Match.json +++ b/PadelClubData/Data/Gen/Match.json @@ -76,6 +76,11 @@ "name": "confirmed", "type": "Bool", "defaultValue": "false" + }, + { + "name": "plannedStartDate", + "type": "Date", + "optional": true } ] } diff --git a/PadelClubData/Data/Gen/Round.json b/PadelClubData/Data/Gen/Round.json index 48a6cf7..ac6b36d 100644 --- a/PadelClubData/Data/Gen/Round.json +++ b/PadelClubData/Data/Gen/Round.json @@ -46,6 +46,11 @@ "name": "loserBracketMode", "type": "LoserBracketMode", "defaultValue": ".automatic" + }, + { + "name": "plannedStartDate", + "type": "Date", + "optional": true } ] } diff --git a/PadelClubData/Data/Gen/Tournament.json b/PadelClubData/Data/Gen/Tournament.json index ce4f01c..6851964 100644 --- a/PadelClubData/Data/Gen/Tournament.json +++ b/PadelClubData/Data/Gen/Tournament.json @@ -348,6 +348,16 @@ "name": "isTemplate", "type": "Bool", "defaultValue": "false" + }, + { + "name": "publishProg", + "type": "Bool", + "defaultValue": "false" + }, + { + "name": "showTeamsInProg", + "type": "Bool", + "defaultValue": "false" } ] } diff --git a/PadelClubData/Data/Tournament.swift b/PadelClubData/Data/Tournament.swift index b01e9a5..a6e6c39 100644 --- a/PadelClubData/Data/Tournament.swift +++ b/PadelClubData/Data/Tournament.swift @@ -112,6 +112,10 @@ final public class Tournament: BaseTournament { public func publishedTournamentDate() -> Date { return min(creationDate.tomorrowAtNine, startDate) } + + public func publishedProgDate() -> Date { + return self.startDate + } public func publishedTeamsDate() -> Date { return self.startDate @@ -129,6 +133,10 @@ final public class Tournament: BaseTournament { public func isTournamentPublished() -> Bool { return (Date() >= publishedTournamentDate()) || publishTournament } + + public func isProgPublished() -> Bool { + return (Date() >= publishedProgDate()) || publishProg + } public func areTeamsPublished() -> Bool { return Date() >= startDate || publishTeams @@ -1681,6 +1689,7 @@ defer { self.publishGroupStages = true self.publishRankings = true self.publishTournament = true + self.publishProg = true #else var shouldBePrivate = templateTournament?.isPrivate ?? true diff --git a/PadelClubData/Utils/URLs.swift b/PadelClubData/Utils/URLs.swift index 67531ba..3eb6c2a 100644 --- a/PadelClubData/Utils/URLs.swift +++ b/PadelClubData/Utils/URLs.swift @@ -58,6 +58,7 @@ public enum URLs: String, Identifiable { public enum PageLink: String, Identifiable, CaseIterable { case info = "Informations" case teams = "Équipes" + case programmation = "Programmation" case summons = "Convocations" case groupStages = "Poules" case matches = "Tournoi" @@ -79,6 +80,8 @@ public enum PageLink: String, Identifiable, CaseIterable { return "info" case .teams: return "teams" + case .programmation: + return "prog" case .summons: return "summons" case .rankings: