paca_championship
Raz 11 months ago
parent a2f0ef63e1
commit 99bf6c40d4
  1. 4
      PadelClub/Data/Tournament.swift
  2. 2
      PadelClub/Views/Navigation/Umpire/PadelClubView.swift
  3. 39
      PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift

@ -1579,7 +1579,7 @@ defer {
teams.forEach { team in
let players = team.unsortedPlayers()
players.forEach { $0.setComputedRank(in: self) }
team.setWeight(from: players, inTournamentCategory: tournamentCategory)
team.setWeight(from: players.sorted(by: \.computedRank), inTournamentCategory: tournamentCategory)
do {
try self.tournamentStore.playerRegistrations.addOrUpdate(contentOfs: players)
} catch {
@ -2120,7 +2120,7 @@ defer {
func addTeam(_ players: Set<PlayerRegistration>, registrationDate: Date? = nil, name: String? = nil) -> TeamRegistration {
let team = TeamRegistration(tournament: id, registrationDate: registrationDate, name: name)
team.setWeight(from: Array(players), inTournamentCategory: tournamentCategory)
team.setWeight(from: players.sorted(by: \.computedRank), inTournamentCategory: tournamentCategory)
players.forEach { player in
player.teamRegistration = team.id
}

@ -269,7 +269,7 @@ func fetchPlayerData(for licenseID: String) async throws -> [Player]? {
request.setValue("XMLHttpRequest", forHTTPHeaderField: "X-Requested-With")
// Add cookies if needed (example cookie header value shown, replace with valid cookies)
request.setValue("JSESSIONID=38707D1E3B920F1EF299827B0DAA7482; AWSALB=0KnoZyXR3dBQyIFtnwMkKwq2fqe4raRSsuD5cz/b0tR2DBXsQ5joyZ5jce0hgr0ZzWH/HJbhUC1L6VS+QbQipIVq7UJllGPpxd7OLjdXcfobfOjsVtpowVa/mHTo; AWSALBCORS=0KnoZyXR3dBQyIFtnwMkKwq2fqe4raRSsuD5cz/b0tR2DBXsQ5joyZ5jce0hgr0ZzWH/HJbhUC1L6VS+QbQipIVq7UJllGPpxd7OLjdXcfobfOjsVtpowVa/mHTo; datadome=4uk4nr8fscpV3E1JEKoO_xAZiFP2Mvb7EJojErst8cZ6MQ0C~0CwqDK8N2h8fFHvysKIsI70rHScAPsn5ZEJXXjSFwi8iPpGu26RbQ6h4dD2IHOI~1CXhx9Ac8oqGziX; xtan=-; xtant=1; tc_cj_v2=%5Ecl_%5Dny%5B%5D%5D_mmZZZZZZKQMMORPMMMQNNZZZ%5D777m_iZZZ%22**%22%27%20ZZZKQMMQMPMPMKOPZZZ%5D; tc_cj_v2_cmp=; tc_cj_v2_med=; tCdebugLib=1; _pcid=%7B%22browserId%22%3A%22m42mi4kbtfuyj367%22%2C%22_t%22%3A%22mjr1fm32%7Cm42mi4r2%22%7D; _pctx=%7Bu%7DN4IgrgzgpgThIC4B2YA2qA05owMoBcBDfSREQpAeyRCwgEt8oBJAE0RXSwH18yBbAFYwAjADN%2BAZgCsAH34AWAEz96CmNJABfIA; _pprv=eyJjb25zZW50Ijp7IjAiOnsibW9kZSI6ImVzc2VudGlhbCJ9LCI3Ijp7Im1vZGUiOiJvcHQtaW4ifX0sInB1cnBvc2VzIjpudWxsLCJfdCI6Im1qcjFmbHdofG00Mm1pNGtoIn0%3D; TCID=124122155494907703483; TCPID=124115115191501043230; xtvrn=$548419$; visid_incap_2712217=PSfJngzoSuiowsuXXhvOu5K+7mUAAAAAQUIPAAAAAAAleL9ldvN/FC1VykkU9ret; SessionStatId=10.91.140.42.1662124965429001", forHTTPHeaderField: "Cookie")
request.setValue("JSESSIONID=5CFF7A6F1230AC61667713BC28678544; AWSALB=d/xUzKCfM7GECEn/bcWJCxohx5dtvae5StpaltCHMlHgLKZIINeHHkh5bdT3Gtf1mSZRofvq5ASKmNxf4RpYSOKL9HZDvk53p+UPvCMqEb+p2RkpFjXbT43126fW; AWSALBCORS=d/xUzKCfM7GECEn/bcWJCxohx5dtvae5StpaltCHMlHgLKZIINeHHkh5bdT3Gtf1mSZRofvq5ASKmNxf4RpYSOKL9HZDvk53p+UPvCMqEb+p2RkpFjXbT43126fW; datadome=0~lpnQzmLCZf10rUJM5M1JqeeBye532qFnJrepPMxCtyZEbNv4k308zHOK1aDQE4QrGWbvqDKRZlnanIg8ha99vQcN5Dd7WEMZSsi48G_wYHFqCGcncSgj614Wsb6Iq0; incap_ses_1516_2712217=K1jaVik65R9vNeZfJuoJFcWxYWcAAAAAFRIA2Xyh5etXOwxALj4oxg==; tc_cj_v2=%5Ecl_%5Dny%5B%5D%5D_mmZZZZZZKQMMORPMMMQNNZZZ%5D777m_iZZZ%22**%22%27%20ZZZKQMMQMPMPMKOPZZZ%5D777%5Ecl_%5Dny%5B%5D%5D_mmZZZZZZKQMNNOOQOJPKJZZZ%5D; tc_cj_v2_cmp=; tc_cj_v2_med=; TCSESSION=12412217413110293677085; incap_ses_2223_2712217=m29uCrVnOVs2aRrB967ZHrCpYWcAAAAA/n/Nxses/KF9jVkBaC+b1Q==; nlbi_2712217=8Fq+T/G90h+rYfntb9lUTgAAAACEOhpdLiUx8E3p9MXJo6vA; xtan=-; xtant=1; tCdebugLib=1; _pcid=%7B%22browserId%22%3A%22m42mi4kbtfuyj367%22%2C%22_t%22%3A%22mjr1fm32%7Cm42mi4r2%22%7D; _pctx=%7Bu%7DN4IgrgzgpgThIC4B2YA2qA05owMoBcBDfSREQpAeyRCwgEt8oBJAE0RXSwH18yBbAFYwAjADN%2BAZgCsAH34AWAEz96CmNJABfIA; _pprv=eyJjb25zZW50Ijp7IjAiOnsibW9kZSI6ImVzc2VudGlhbCJ9LCI3Ijp7Im1vZGUiOiJvcHQtaW4ifX0sInB1cnBvc2VzIjpudWxsLCJfdCI6Im1qcjFmbHdofG00Mm1pNGtoIn0%3D; TCID=124122155494907703483; TCPID=124115115191501043230; xtvrn=$548419$; visid_incap_2712217=PSfJngzoSuiowsuXXhvOu5K+7mUAAAAAQUIPAAAAAAAleL9ldvN/FC1VykkU9ret; SessionStatId=10.91.140.42.1662124965429001", forHTTPHeaderField: "Cookie")
let (data, _) = try await URLSession.shared.data(for: request)
let decoder = JSONDecoder()

@ -52,7 +52,10 @@ struct InscriptionManagerView: View {
@State private var refreshResult: String? = nil
@State private var refreshInProgress: Bool = false
@State private var refreshStatus: Bool?
@State private var gatheringInProgress: Bool = false
@State private var gathered: Double = 0
@State private var gatheringDone: Bool = false
var tournamentStore: TournamentStore {
return self.tournament.tournamentStore
}
@ -631,6 +634,10 @@ struct InscriptionManagerView: View {
_teamDeleteButtonView(team)
}
.listRowView(isActive: true, color: team.initialRoundColor() ?? tournament.cutLabelColor(index: teamIndex, teamCount: filterMode == .waiting ? 0 : selectedSortedTeams.count), hideColorVariation: true)
.onAppear {
let w = team.players().prefix(6).map({ $0.computedRank }).reduce(0,+)
print(team.teamLabel(), w, team.weight)
}
}
} header: {
if filterMode == .all && walkoutTeams.isEmpty == false {
@ -865,9 +872,13 @@ struct InscriptionManagerView: View {
}
}
Button("Récupérer les non-classés") {
let unrankedUnsourced = tournament.players().filter({ $0.isUnranked() && $0.source == nil })
Button {
Task {
for player in tournament.players().filter({ $0.isUnranked() && $0.source == nil }) {
gatheringInProgress = true
gathered = 0
gatheringDone = false
for player in unrankedUnsourced {
do {
if let playerData = try await player.fetchUnrankPlayerData() {
player.lastName = playerData.nom
@ -875,13 +886,33 @@ struct InscriptionManagerView: View {
player.clubCode = playerData.codeClub
player.source = .frenchFederation
try tournamentStore.playerRegistrations.addOrUpdate(instance: player)
await MainActor.run {
gathered += 1
}
}
} catch {
print(error)
}
}
gatheringDone = true
}
} label: {
if gatheringInProgress {
ProgressView("Récupérés", value: gathered, total: Double(unrankedUnsourced.count))
} else {
LabeledContent {
if gatheringDone {
Image(systemName: "checkmark").foregroundStyle(.green)
}
} label: {
Text("Récupérer les non-classés")
}
}
}
Button("Recalculer les poids") {
tournament.updateWeights()
_setHash()
}
} header: {
HStack {

Loading…
Cancel
Save