@ -48,8 +48,6 @@ class Tournament : ModelObject, Storable {
var publishSummons : Bool = false
var publishGroupStages : Bool = false
var publishBrackets : Bool = false
// l o c a l
var shouldVerifyGroupStage : Bool = false
var shouldVerifyBracket : Bool = false
@ -94,9 +92,11 @@ class Tournament : ModelObject, Storable {
case _publishSummons = " publishSummons "
case _publishGroupStages = " publishGroupStages "
case _publishBrackets = " publishBrackets "
case _shouldVerifyGroupStage = " shouldVerifyGroupStage "
case _shouldVerifyBracket = " shouldVerifyBracket "
}
internal init ( event : String ? = nil , name : String ? = nil , startDate : Date = Date ( ) , endDate : Date ? = nil , creationDate : Date = Date ( ) , isPrivate : Bool = false , groupStageFormat : MatchFormat ? = nil , roundFormat : MatchFormat ? = nil , loserRoundFormat : MatchFormat ? = nil , groupStageSortMode : GroupStageOrderingMode , groupStageCount : Int = 4 , rankSourceDate : Date ? = nil , dayDuration : Int = 1 , teamCount : Int = 24 , teamSorting : TeamSortingType ? = nil , federalCategory : TournamentCategory , federalLevelCategory : TournamentLevel , federalAgeCategory : FederalTournamentAge , closedRegistrationDate : Date ? = nil , groupStageAdditionalQualified : Int = 0 , courtCount : Int = 2 , prioritizeClubMembers : Bool = false , qualifiedPerGroupStage : Int = 1 , teamsPerGroupStage : Int = 4 , entryFee : Double ? = nil , additionalEstimationDuration : Int = 0 , isDeleted : Bool = false , publishTeams : Bool = false , publishSummons : Bool = false , publishGroupStages : Bool = false , publishBrackets : Bool = false ) {
internal init ( event : String ? = nil , name : String ? = nil , startDate : Date = Date ( ) , endDate : Date ? = nil , creationDate : Date = Date ( ) , isPrivate : Bool = false , groupStageFormat : MatchFormat ? = nil , roundFormat : MatchFormat ? = nil , loserRoundFormat : MatchFormat ? = nil , groupStageSortMode : GroupStageOrderingMode , groupStageCount : Int = 4 , rankSourceDate : Date ? = nil , dayDuration : Int = 1 , teamCount : Int = 24 , teamSorting : TeamSortingType ? = nil , federalCategory : TournamentCategory , federalLevelCategory : TournamentLevel , federalAgeCategory : FederalTournamentAge , closedRegistrationDate : Date ? = nil , groupStageAdditionalQualified : Int = 0 , courtCount : Int = 2 , prioritizeClubMembers : Bool = false , qualifiedPerGroupStage : Int = 1 , teamsPerGroupStage : Int = 4 , entryFee : Double ? = nil , additionalEstimationDuration : Int = 0 , isDeleted : Bool = false , publishTeams : Bool = false , publishSummons : Bool = false , publishGroupStages : Bool = false , publishBrackets : Bool = false , shouldVerifyBracket : Bool = false , shouldVerifyGroupStage : Bool = false ) {
self . event = event
self . name = name
self . startDate = startDate
@ -128,6 +128,8 @@ class Tournament : ModelObject, Storable {
self . publishSummons = publishSummons
self . publishBrackets = publishBrackets
self . publishGroupStages = publishGroupStages
self . shouldVerifyBracket = shouldVerifyBracket
self . shouldVerifyGroupStage = shouldVerifyGroupStage
}
required init ( from decoder : Decoder ) throws {
@ -166,7 +168,8 @@ class Tournament : ModelObject, Storable {
publishSummons = try container . decodeIfPresent ( Bool . self , forKey : . _publishSummons ) ? ? false
publishGroupStages = try container . decodeIfPresent ( Bool . self , forKey : . _publishGroupStages ) ? ? false
publishBrackets = try container . decodeIfPresent ( Bool . self , forKey : . _publishBrackets ) ? ? false
shouldVerifyBracket = try container . decodeIfPresent ( Bool . self , forKey : . _shouldVerifyBracket ) ? ? false
shouldVerifyGroupStage = try container . decodeIfPresent ( Bool . self , forKey : . _shouldVerifyGroupStage ) ? ? false
}
fileprivate static let _numberFormatter : NumberFormatter = NumberFormatter ( )
@ -276,6 +279,8 @@ class Tournament : ModelObject, Storable {
try container . encode ( publishSummons , forKey : . _publishSummons )
try container . encode ( publishBrackets , forKey : . _publishBrackets )
try container . encode ( publishGroupStages , forKey : . _publishGroupStages )
try container . encode ( shouldVerifyBracket , forKey : . _shouldVerifyBracket )
try container . encode ( shouldVerifyGroupStage , forKey : . _shouldVerifyGroupStage )
}
fileprivate func _encodePayment ( container : inout KeyedEncodingContainer < CodingKeys > ) throws {
@ -1152,6 +1157,15 @@ class Tournament : ModelObject, Storable {
return TournamentStatus ( label : label , completion : completionLabel )
}
func confirmedSummonStatus ( ) -> TournamentStatus {
let selectedSortedTeams = selectedSortedTeams ( )
let called = selectedSortedTeams . filter { $0 . confirmationDate != nil }
let label = called . count . formatted ( ) + " / " + selectedSortedTeams . count . formatted ( ) + " confirmées "
let completion = ( Double ( called . count ) / Double ( selectedSortedTeams . count ) )
let completionLabel = completion . isNaN ? " " : completion . formatted ( . percent . precision ( . fractionLength ( 0 ) ) )
return TournamentStatus ( label : label , completion : completionLabel )
}
func bracketStatus ( ) -> String {
let availableSeeds = availableSeeds ( )
if availableSeeds . isEmpty = = false {