|
|
|
@ -95,7 +95,7 @@ class GroupStage: ModelObject, Storable { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func scoreLabel(forGroupStagePosition groupStagePosition: Int) -> (wins: String, losses: String, setsDifference: String?, gamesDifference: String?)? { |
|
|
|
func scoreLabel(forGroupStagePosition groupStagePosition: Int) -> (wins: String, losses: String, setsDifference: String?, gamesDifference: String?)? { |
|
|
|
if let scoreData = _score(forGroupStagePosition: groupStagePosition) { |
|
|
|
if let scoreData = _score(forGroupStagePosition: groupStagePosition, nilIfEmpty: true) { |
|
|
|
let hideSetDifference = matchFormat.setsToWin == 1 |
|
|
|
let hideSetDifference = matchFormat.setsToWin == 1 |
|
|
|
let setDifference = scoreData.setDifference.formatted(.number.sign(strategy: .always(includingZero: false))) |
|
|
|
let setDifference = scoreData.setDifference.formatted(.number.sign(strategy: .always(includingZero: false))) |
|
|
|
let gameDifference = scoreData.gameDifference.formatted(.number.sign(strategy: .always(includingZero: false))) |
|
|
|
let gameDifference = scoreData.gameDifference.formatted(.number.sign(strategy: .always(includingZero: false))) |
|
|
|
@ -106,10 +106,10 @@ class GroupStage: ModelObject, Storable { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fileprivate func _score(forGroupStagePosition groupStagePosition: Int) -> TeamGroupStageScore? { |
|
|
|
fileprivate func _score(forGroupStagePosition groupStagePosition: Int, nilIfEmpty: Bool = false) -> TeamGroupStageScore? { |
|
|
|
guard let team = teamAt(groupStagePosition: groupStagePosition) else { return nil } |
|
|
|
guard let team = teamAt(groupStagePosition: groupStagePosition) else { return nil } |
|
|
|
let matches = matches(forGroupStagePosition: groupStagePosition).filter({ $0.hasEnded() }) |
|
|
|
let matches = matches(forGroupStagePosition: groupStagePosition).filter({ $0.hasEnded() }) |
|
|
|
if matches.isEmpty { return nil } |
|
|
|
if matches.isEmpty && nilIfEmpty { return nil } |
|
|
|
let wins = matches.filter { $0.winningTeamId == team.id }.count |
|
|
|
let wins = matches.filter { $0.winningTeamId == team.id }.count |
|
|
|
let loses = matches.filter { $0.losingTeamId == team.id }.count |
|
|
|
let loses = matches.filter { $0.losingTeamId == team.id }.count |
|
|
|
let differences = matches.compactMap { $0.scoreDifference(groupStagePosition) } |
|
|
|
let differences = matches.compactMap { $0.scoreDifference(groupStagePosition) } |
|
|
|
|