sync2
Raz 1 year ago
parent 09d7852c87
commit 556f57004d
  1. 9
      PadelClub/Data/Tournament.swift
  2. 2
      PadelClub/Views/GroupStage/GroupStagesView.swift
  3. 18
      PadelClub/Views/Round/RoundView.swift
  4. 3
      PadelClub/Views/Tournament/Screen/TournamentRankView.swift
  5. 3
      PadelClub/Views/Tournament/TournamentRunningView.swift

@ -1151,7 +1151,7 @@ defer {
return allMatches.filter({ $0.isReady() && $0.isRunning() == false && $0.hasEnded() == false }).sorted(by: \.computedStartDateForSorting) return allMatches.filter({ $0.isReady() && $0.isRunning() == false && $0.hasEnded() == false }).sorted(by: \.computedStartDateForSorting)
} }
func finishedMatches(_ allMatches: [Match], limit: Int? = nil) -> [Match] { func finishedMatches(_ allMatches: [Match], limit: Int?) -> [Match] {
#if _DEBUG_TIME //DEBUGING TIME #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
@ -1159,8 +1159,11 @@ defer {
print("func tournament finishedMatches", id, duration.formatted(.units(allowed: [.seconds, .milliseconds]))) print("func tournament finishedMatches", id, duration.formatted(.units(allowed: [.seconds, .milliseconds])))
} }
#endif #endif
let _limit = limit ?? courtCount if let limit {
return Array(allMatches.filter({ $0.hasEnded() }).sorted(by: \.computedEndDateForSorting).reversed().prefix(_limit)) return Array(allMatches.filter({ $0.hasEnded() }).sorted(by: \.computedEndDateForSorting).reversed().prefix(limit))
} else {
return Array(allMatches.filter({ $0.hasEnded() }).sorted(by: \.computedEndDateForSorting).reversed())
}
} }
func teamsRanked() -> [TeamRegistration] { func teamsRanked() -> [TeamRegistration] {

@ -109,7 +109,7 @@ struct GroupStagesView: View {
GenericDestinationPickerView(selectedDestination: $selectedDestination, destinations: allDestinations(), nilDestinationIsValid: true) GenericDestinationPickerView(selectedDestination: $selectedDestination, destinations: allDestinations(), nilDestinationIsValid: true)
switch selectedDestination { switch selectedDestination {
case .all: case .all:
let finishedMatches = tournament.finishedMatches(allMatches) let finishedMatches = tournament.finishedMatches(allMatches, limit: nil)
List { List {
if tournament.groupStageAdditionalQualified > 0 { if tournament.groupStageAdditionalQualified > 0 {

@ -74,15 +74,17 @@ struct RoundView: View {
let bracketTip = BracketEditTip(nextRoundName: upperRound.round.nextRound()?.roundTitle()) let bracketTip = BracketEditTip(nextRoundName: upperRound.round.nextRound()?.roundTitle())
TipView(bracketTip).tipStyle(tint: .green, asSection: true) TipView(bracketTip).tipStyle(tint: .green, asSection: true)
Section { if upperRound.round.hasStarted() == false {
let leftToPlay = (RoundRule.numberOfMatches(forRoundIndex: upperRound.round.index) - disabledMatchesCount) Section {
LabeledContent { let leftToPlay = (RoundRule.numberOfMatches(forRoundIndex: upperRound.round.index) - disabledMatchesCount)
Text(leftToPlay.formatted()) LabeledContent {
} label: { Text(leftToPlay.formatted())
Text("Match\(leftToPlay.pluralSuffix) à jouer \(upperRound.title)") } label: {
Text("Match\(leftToPlay.pluralSuffix) à jouer \(upperRound.title)")
}
} footer: {
Text("\(disabledMatchesCount) match\(disabledMatchesCount.pluralSuffix) désactivé\(disabledMatchesCount.pluralSuffix) automatiquement")
} }
} footer: {
Text("\(disabledMatchesCount) match\(disabledMatchesCount.pluralSuffix) désactivé\(disabledMatchesCount.pluralSuffix) automatiquement")
} }
} }

@ -106,6 +106,7 @@ struct TournamentRankView: View {
} }
} }
} }
.id(calculating)
.alert("Position", isPresented: isEditingTeam) { .alert("Position", isPresented: isEditingTeam) {
if let selectedTeam { if let selectedTeam {
@Bindable var team = selectedTeam @Bindable var team = selectedTeam
@ -154,6 +155,7 @@ struct TournamentRankView: View {
} }
struct TeamRankCellView: View { struct TeamRankCellView: View {
@EnvironmentObject var dataStore: DataStore
@Environment(\.editMode) private var editMode @Environment(\.editMode) private var editMode
@Environment(Tournament.self) var tournament: Tournament @Environment(Tournament.self) var tournament: Tournament
@State private var isEditingTeam: Bool = false @State private var isEditingTeam: Bool = false
@ -306,6 +308,7 @@ struct TournamentRankView: View {
calculating = true calculating = true
} }
self.rankings.removeAll()
let finalRanks = await tournament.finalRanking() let finalRanks = await tournament.finalRanking()
finalRanks.keys.sorted().forEach { rank in finalRanks.keys.sorted().forEach { rank in
if let rankedTeamIds = finalRanks[rank] { if let rankedTeamIds = finalRanks[rank] {

@ -21,7 +21,8 @@ struct TournamentRunningView: View {
MatchListView(section: "en cours", matches: tournament.runningMatches(allMatches), hideWhenEmpty: tournament.hasEnded()) MatchListView(section: "en cours", matches: tournament.runningMatches(allMatches), hideWhenEmpty: tournament.hasEnded())
// MatchListView(section: "à lancer", matches: tournament.readyMatches(allMatches), isExpanded: false) // MatchListView(section: "à lancer", matches: tournament.readyMatches(allMatches), isExpanded: false)
// MatchListView(section: "disponible", matches: tournament.availableToStart(allMatches), isExpanded: false) // MatchListView(section: "disponible", matches: tournament.availableToStart(allMatches), isExpanded: false)
MatchListView(section: "terminés", matches: tournament.finishedMatches(allMatches), isExpanded: tournament.hasEnded()) let finishedMatches = tournament.finishedMatches(allMatches, limit: tournament.courtCount)
MatchListView(section: "Dernier\(finishedMatches.count.pluralSuffix) match\(finishedMatches.count.pluralSuffix) terminé\(finishedMatches.count.pluralSuffix)", matches: finishedMatches, isExpanded: tournament.hasEnded())
} }
} }

Loading…
Cancel
Save