@ -1094,22 +1094,45 @@ class Tournament : ModelObject, Storable {
}
let others : [ Round ] = rounds . flatMap { round in
round . loserRoundsAndChildren ( ) . filter { $0 . isRankDisabled ( ) = = false && $0 . hasNextRound ( ) = = false }
print ( " round " , round . roundTitle ( ) )
let rounds = round . loserRoundsAndChildren ( ) . filter { $0 . isRankDisabled ( ) = = false && $0 . hasNextRound ( ) = = false }
print ( rounds . count , rounds . map { $0 . roundTitle ( ) } )
return rounds
} . compactMap ( { $0 } )
others . forEach { round in
print ( " round " , round . roundTitle ( ) )
if let interval = round . seedInterval ( ) {
print ( " interval " , interval . localizedLabel ( ) )
let playedMatches = round . playedMatches ( ) . filter { $0 . disabled = = false || $0 . isReady ( ) }
print ( " playedMatches " , playedMatches . count )
let winners = playedMatches . compactMap ( { $0 . winningTeamId } ) . filter ( { ids . contains ( $0 ) = = false } )
print ( " winners " , winners . count )
let losers = playedMatches . compactMap ( { $0 . losingTeamId } ) . filter ( { ids . contains ( $0 ) = = false } )
print ( " losers " , losers . count )
if winners . isEmpty {
let disabledIds = playedMatches . flatMap ( { $0 . teamScores . compactMap ( { $0 . teamRegistration } ) } ) . filter ( { ids . contains ( $0 ) = = false } )
teams [ interval . last ] = disabledIds
teams [ interval . computedLast ] = disabledIds
let teamNames : [ String ] = disabledIds . compactMap {
let t : TeamRegistration ? = Store . main . findById ( $0 )
return t
} . map { $0 . canonicalName }
print ( " winners.isEmpty " , " \( interval . computedLast ) : " , teamNames )
disabledIds . forEach { ids . insert ( $0 ) }
} else {
teams [ interval . first + winners . count - 1 ] = winners
teams [ interval . computedFirst + winners . count - 1 ] = winners
let teamNames : [ String ] = winners . compactMap {
let t : TeamRegistration ? = Store . main . findById ( $0 )
return t
} . map { $0 . canonicalName }
print ( " winners " , " \( interval . computedFirst + winners . count - 1 ) : " , teamNames )
winners . forEach { ids . insert ( $0 ) }
teams [ interval . last ] = losers
teams [ interval . computedLast ] = losers
let loserTeamNames : [ String ] = losers . compactMap {
let t : TeamRegistration ? = Store . main . findById ( $0 )
return t
} . map { $0 . canonicalName }
print ( " losers " , " \( interval . computedLast ) : " , loserTeamNames )
losers . forEach { ids . insert ( $0 ) }
}
}