|
|
|
@ -433,6 +433,22 @@ final class TeamRegistration: ModelObject, Storable { |
|
|
|
|
|
|
|
|
|
|
|
func updatePlayers(_ players: Set<PlayerRegistration>, inTournamentCategory tournamentCategory: TournamentCategory) { |
|
|
|
func updatePlayers(_ players: Set<PlayerRegistration>, inTournamentCategory tournamentCategory: TournamentCategory) { |
|
|
|
let previousPlayers = Set(unsortedPlayers()) |
|
|
|
let previousPlayers = Set(unsortedPlayers()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
players.forEach { player in |
|
|
|
|
|
|
|
previousPlayers.forEach { oldPlayer in |
|
|
|
|
|
|
|
if player.licenceId?.strippedLicense == oldPlayer.licenceId?.strippedLicense, player.licenceId?.strippedLicense != nil { |
|
|
|
|
|
|
|
player.registeredOnline = oldPlayer.registeredOnline |
|
|
|
|
|
|
|
player.coach = oldPlayer.coach |
|
|
|
|
|
|
|
player.tournamentPlayed = oldPlayer.tournamentPlayed |
|
|
|
|
|
|
|
player.points = oldPlayer.points |
|
|
|
|
|
|
|
player.captain = oldPlayer.captain |
|
|
|
|
|
|
|
player.assimilation = oldPlayer.assimilation |
|
|
|
|
|
|
|
player.ligueName = oldPlayer.ligueName |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let playersToRemove = previousPlayers.subtracting(players) |
|
|
|
let playersToRemove = previousPlayers.subtracting(players) |
|
|
|
do { |
|
|
|
do { |
|
|
|
try self.tournamentStore.playerRegistrations.delete(contentOfs: playersToRemove) |
|
|
|
try self.tournamentStore.playerRegistrations.delete(contentOfs: playersToRemove) |
|
|
|
@ -443,7 +459,13 @@ final class TeamRegistration: ModelObject, Storable { |
|
|
|
|
|
|
|
|
|
|
|
players.forEach { player in |
|
|
|
players.forEach { player in |
|
|
|
player.teamRegistration = id |
|
|
|
player.teamRegistration = id |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// do { |
|
|
|
|
|
|
|
// try self.tournamentStore.playerRegistrations.addOrUpdate(contentOfs: players) |
|
|
|
|
|
|
|
// } catch { |
|
|
|
|
|
|
|
// Logger.error(error) |
|
|
|
|
|
|
|
// } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
typealias TeamRange = (left: TeamRegistration?, right: TeamRegistration?) |
|
|
|
typealias TeamRange = (left: TeamRegistration?, right: TeamRegistration?) |
|
|
|
|