|
|
|
|
@ -63,7 +63,6 @@ final class Tournament : ModelObject, Storable { |
|
|
|
|
var enableOnlineRegistration: Bool = false |
|
|
|
|
var registrationDateLimit: Date? = nil |
|
|
|
|
var openingRegistrationDate: Date? = nil |
|
|
|
|
var targetTeamCount: Int? = nil |
|
|
|
|
var waitingListLimit: Int? = nil |
|
|
|
|
var accountIsRequired: Bool = true |
|
|
|
|
var licenseIsRequired: Bool = true |
|
|
|
|
@ -124,7 +123,6 @@ final class Tournament : ModelObject, Storable { |
|
|
|
|
case _enableOnlineRegistration = "enableOnlineRegistration" |
|
|
|
|
case _registrationDateLimit = "registrationDateLimit" |
|
|
|
|
case _openingRegistrationDate = "openingRegistrationDate" |
|
|
|
|
case _targetTeamCount = "targetTeamCount" |
|
|
|
|
case _waitingListLimit = "waitingListLimit" |
|
|
|
|
case _accountIsRequired = "accountIsRequired" |
|
|
|
|
case _licenseIsRequired = "licenseIsRequired" |
|
|
|
|
@ -134,7 +132,7 @@ final class Tournament : ModelObject, Storable { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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, hideTeamsWeight: Bool = false, publishTournament: Bool = false, hidePointsEarned: Bool = false, publishRankings: Bool = false, loserBracketMode: LoserBracketMode = .automatic, initialSeedRound: Int = 0, initialSeedCount: Int = 0, enableOnlineRegistration: Bool = false, registrationDateLimit: Date? = nil, openingRegistrationDate: Date? = nil, targetTeamCount: Int? = nil, waitingListLimit: Int? = nil, accountIsRequired: Bool = true, licenseIsRequired: Bool = true, minimumPlayerPerTeam: Int = 2, maximumPlayerPerTeam: Int = 2, information: String? = nil) { |
|
|
|
|
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, hideTeamsWeight: Bool = false, publishTournament: Bool = false, hidePointsEarned: Bool = false, publishRankings: Bool = false, loserBracketMode: LoserBracketMode = .automatic, initialSeedRound: Int = 0, initialSeedCount: Int = 0, enableOnlineRegistration: Bool = false, registrationDateLimit: Date? = nil, openingRegistrationDate: Date? = nil, waitingListLimit: Int? = nil, accountIsRequired: Bool = true, licenseIsRequired: Bool = true, minimumPlayerPerTeam: Int = 2, maximumPlayerPerTeam: Int = 2, information: String? = nil) { |
|
|
|
|
self.event = event |
|
|
|
|
self.name = name |
|
|
|
|
self.startDate = startDate |
|
|
|
|
@ -191,7 +189,6 @@ final class Tournament : ModelObject, Storable { |
|
|
|
|
self.enableOnlineRegistration = enableOnlineRegistration |
|
|
|
|
self.registrationDateLimit = registrationDateLimit |
|
|
|
|
self.openingRegistrationDate = openingRegistrationDate |
|
|
|
|
self.targetTeamCount = targetTeamCount |
|
|
|
|
self.waitingListLimit = waitingListLimit |
|
|
|
|
|
|
|
|
|
self.accountIsRequired = accountIsRequired |
|
|
|
|
@ -249,7 +246,6 @@ final class Tournament : ModelObject, Storable { |
|
|
|
|
enableOnlineRegistration = try container.decodeIfPresent(Bool.self, forKey: ._enableOnlineRegistration) ?? false |
|
|
|
|
registrationDateLimit = try container.decodeIfPresent(Date.self, forKey: ._registrationDateLimit) |
|
|
|
|
openingRegistrationDate = try container.decodeIfPresent(Date.self, forKey: ._openingRegistrationDate) |
|
|
|
|
targetTeamCount = try container.decodeIfPresent(Int.self, forKey: ._targetTeamCount) |
|
|
|
|
waitingListLimit = try container.decodeIfPresent(Int.self, forKey: ._waitingListLimit) |
|
|
|
|
accountIsRequired = try container.decodeIfPresent(Bool.self, forKey: ._accountIsRequired) ?? true |
|
|
|
|
licenseIsRequired = try container.decodeIfPresent(Bool.self, forKey: ._licenseIsRequired) ?? true |
|
|
|
|
@ -348,7 +344,6 @@ final class Tournament : ModelObject, Storable { |
|
|
|
|
try container.encode(enableOnlineRegistration, forKey: ._enableOnlineRegistration) |
|
|
|
|
try container.encode(registrationDateLimit, forKey: ._registrationDateLimit) |
|
|
|
|
try container.encode(openingRegistrationDate, forKey: ._openingRegistrationDate) |
|
|
|
|
try container.encode(targetTeamCount, forKey: ._targetTeamCount) |
|
|
|
|
try container.encode(waitingListLimit, forKey: ._waitingListLimit) |
|
|
|
|
|
|
|
|
|
try container.encode(accountIsRequired, forKey: ._accountIsRequired) |
|
|
|
|
@ -2490,19 +2485,16 @@ defer { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if let targetTeamCount = targetTeamCount { |
|
|
|
|
// Get all team registrations excluding walk_outs |
|
|
|
|
let currentTeamCount = unsortedTeamsWithoutWO().count |
|
|
|
|
|
|
|
|
|
if currentTeamCount >= targetTeamCount { |
|
|
|
|
if let waitingListLimit = waitingListLimit { |
|
|
|
|
let waitingListCount = currentTeamCount - targetTeamCount |
|
|
|
|
if waitingListCount >= waitingListLimit { |
|
|
|
|
return .waitingListFull |
|
|
|
|
} |
|
|
|
|
let currentTeamCount = unsortedTeamsWithoutWO().count |
|
|
|
|
|
|
|
|
|
if currentTeamCount >= teamCount { |
|
|
|
|
if let waitingListLimit = waitingListLimit { |
|
|
|
|
let waitingListCount = currentTeamCount - teamCount |
|
|
|
|
if waitingListCount >= waitingListLimit { |
|
|
|
|
return .waitingListFull |
|
|
|
|
} |
|
|
|
|
return .waitingListPossible |
|
|
|
|
} |
|
|
|
|
return .waitingListPossible |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return .open |
|
|
|
|
|