|
|
|
|
@ -55,6 +55,7 @@ struct InscriptionManagerView: View { |
|
|
|
|
@State private var gatheringInProgress: Bool = false |
|
|
|
|
@State private var gathered: Double = 0 |
|
|
|
|
@State private var gatheringDone: Bool = false |
|
|
|
|
@State private var totalUnrankedUnsourced: Double = 0 |
|
|
|
|
|
|
|
|
|
var tournamentStore: TournamentStore { |
|
|
|
|
return self.tournament.tournamentStore |
|
|
|
|
@ -872,13 +873,14 @@ struct InscriptionManagerView: View { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let unrankedUnsourced = tournament.players().filter({ $0.isUnranked() && $0.source == nil }) |
|
|
|
|
Button { |
|
|
|
|
Task { |
|
|
|
|
gatheringInProgress = true |
|
|
|
|
gathered = 0 |
|
|
|
|
gatheringDone = false |
|
|
|
|
print("total", unrankedUnsourced) |
|
|
|
|
let unrankedUnsourced = tournament.players().filter({ $0.isUnranked() && $0.source == nil }) |
|
|
|
|
totalUnrankedUnsourced = Double(unrankedUnsourced.count) |
|
|
|
|
print("total", unrankedUnsourced.count) |
|
|
|
|
for player in unrankedUnsourced { |
|
|
|
|
do { |
|
|
|
|
if let playerData = try await player.fetchUnrankPlayerData() { |
|
|
|
|
@ -887,20 +889,25 @@ struct InscriptionManagerView: View { |
|
|
|
|
player.clubCode = playerData.codeClub |
|
|
|
|
player.source = .frenchFederation |
|
|
|
|
try tournamentStore.playerRegistrations.addOrUpdate(instance: player) |
|
|
|
|
await MainActor.run { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
gathered += 1 |
|
|
|
|
print("gathered", gathered) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} catch { |
|
|
|
|
print(error) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
gatheringDone = true |
|
|
|
|
gatheringInProgress = false |
|
|
|
|
} |
|
|
|
|
} label: { |
|
|
|
|
if gatheringInProgress { |
|
|
|
|
ProgressView("Récupérés", value: gathered, total: Double(unrankedUnsourced.count)) |
|
|
|
|
LabeledContent { |
|
|
|
|
Text("\(gathered.formatted()) / \(totalUnrankedUnsourced.formatted())") |
|
|
|
|
} label: { |
|
|
|
|
ProgressView("Récupérés", value: gathered, total: totalUnrankedUnsourced) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
LabeledContent { |
|
|
|
|
if gatheringDone { |
|
|
|
|
|