fix registration issues lag

swap default settings for scheduler
paca_championship
Raz 1 year ago
parent 9b0bb5efe5
commit 131ee06fd4
  1. 9
      PadelClub/Data/MatchScheduler.swift
  2. 6
      PadelClub/Data/Tournament.swift
  3. 13
      PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift

@ -30,7 +30,7 @@ final class MatchScheduler : ModelObject, Storable {
var shouldEndRoundBeforeStartingNext: Bool var shouldEndRoundBeforeStartingNext: Bool
var groupStageChunkCount: Int? var groupStageChunkCount: Int?
var overrideCourtsUnavailability: Bool = false var overrideCourtsUnavailability: Bool = false
var shouldTryToFillUpCourtsAvailable: Bool = false var shouldTryToFillUpCourtsAvailable: Bool = true
var courtsAvailable: Set<Int> = Set<Int>() var courtsAvailable: Set<Int> = Set<Int>()
init(tournament: String, init(tournament: String,
@ -41,9 +41,12 @@ final class MatchScheduler : ModelObject, Storable {
accountLoserBracketBreakTime: Bool = false, accountLoserBracketBreakTime: Bool = false,
randomizeCourts: Bool = true, randomizeCourts: Bool = true,
rotationDifferenceIsImportant: Bool = false, rotationDifferenceIsImportant: Bool = false,
shouldHandleUpperRoundSlice: Bool = true, shouldHandleUpperRoundSlice: Bool = false,
shouldEndRoundBeforeStartingNext: Bool = true, shouldEndRoundBeforeStartingNext: Bool = true,
groupStageChunkCount: Int? = nil, overrideCourtsUnavailability: Bool = false, shouldTryToFillUpCourtsAvailable: Bool = false, courtsAvailable: Set<Int> = Set<Int>()) { groupStageChunkCount: Int? = nil,
overrideCourtsUnavailability: Bool = false,
shouldTryToFillUpCourtsAvailable: Bool = true,
courtsAvailable: Set<Int> = Set<Int>()) {
self.tournament = tournament self.tournament = tournament
self.timeDifferenceLimit = timeDifferenceLimit self.timeDifferenceLimit = timeDifferenceLimit
self.loserBracketRotationDifference = loserBracketRotationDifference self.loserBracketRotationDifference = loserBracketRotationDifference

@ -800,13 +800,13 @@ defer {
func selectedSortedTeams() -> [TeamRegistration] { func selectedSortedTeams() -> [TeamRegistration] {
#if _DEBUG_TIME //DEBUGING TIME // #if _DEBUG_TIME //DEBUGING TIME
let start = Date() let start = Date()
defer { defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)
print("func selectedSortedTeams", id, tournamentTitle(), duration.formatted(.units(allowed: [.seconds, .milliseconds]))) print("func selectedSortedTeams", id, tournamentTitle(), duration.formatted(.units(allowed: [.seconds, .milliseconds])))
} }
#endif // #endif
var _sortedTeams : [TeamRegistration] = [] var _sortedTeams : [TeamRegistration] = []
var _teams = unsortedTeams().filter({ $0.walkOut == false }) var _teams = unsortedTeams().filter({ $0.walkOut == false })
@ -1081,7 +1081,7 @@ defer {
} }
} }
func registrationIssues() -> Int { func registrationIssues() async -> Int {
let players : [PlayerRegistration] = unsortedPlayers() let players : [PlayerRegistration] = unsortedPlayers()
let selectedTeams : [TeamRegistration] = selectedSortedTeams() let selectedTeams : [TeamRegistration] = selectedSortedTeams()
let callDateIssue : [TeamRegistration] = selectedTeams.filter { $0.callDate != nil && isStartDateIsDifferentThanCallDate($0) } let callDateIssue : [TeamRegistration] = selectedTeams.filter { $0.callDate != nil && isStartDateIsDifferentThanCallDate($0) }

@ -48,6 +48,7 @@ struct InscriptionManagerView: View {
@State private var presentAddTeamView: Bool = false @State private var presentAddTeamView: Bool = false
@State private var compactMode: Bool = true @State private var compactMode: Bool = true
@State private var pasteString: String? @State private var pasteString: String?
@State private var registrationIssues: Int? = nil
var tournamentStore: TournamentStore { var tournamentStore: TournamentStore {
return self.tournament.tournamentStore return self.tournament.tournamentStore
@ -164,6 +165,9 @@ struct InscriptionManagerView: View {
if self.teamsHash == nil, selectedSortedTeams.isEmpty == false { if self.teamsHash == nil, selectedSortedTeams.isEmpty == false {
self.teamsHash = _simpleHash(ids: selectedSortedTeams.map { $0.id }) self.teamsHash = _simpleHash(ids: selectedSortedTeams.map { $0.id })
} }
Task {
self.registrationIssues = await tournament.registrationIssues()
}
} }
private func _handleHashDiff() { private func _handleHashDiff() {
@ -700,16 +704,19 @@ struct InscriptionManagerView: View {
.fixedSize(horizontal: false, vertical: false) .fixedSize(horizontal: false, vertical: false)
.listRowSeparator(.hidden) .listRowSeparator(.hidden)
let registrationIssues = tournament.registrationIssues() if tournament.isAnimation() == false {
if tournament.isAnimation() == false, registrationIssues > 0 {
NavigationLink { NavigationLink {
InscriptionInfoView() InscriptionInfoView()
.environment(tournament) .environment(tournament)
} label: { } label: {
LabeledContent { LabeledContent {
Text(tournament.registrationIssues().formatted()) if let registrationIssues {
Text(registrationIssues.formatted())
.foregroundStyle(.logoRed) .foregroundStyle(.logoRed)
.fontWeight(.bold) .fontWeight(.bold)
} else {
ProgressView()
}
} label: { } label: {
Text("Problèmes détectés") Text("Problèmes détectés")
} }

Loading…
Cancel
Save