remove unregistered var

online_reg
Raz 11 months ago
parent 15b5ba97f9
commit 768902e827
  1. 20
      PadelClub/Data/TeamRegistration.swift
  2. 28
      PadelClub/Views/Team/EditingTeamView.swift
  3. 12
      PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift
  4. 4
      PadelClubTests/ServerDataTests.swift

@ -39,22 +39,15 @@ final class TeamRegistration: ModelObject, Storable {
var finalRanking: Int? var finalRanking: Int?
var pointsEarned: Int? var pointsEarned: Int?
var unregistered: Bool = false
var unregistrationDate: Date? = nil
func hasUnregistered() -> Bool {
unregistered
}
func hasRegisteredOnline() -> Bool { func hasRegisteredOnline() -> Bool {
players().anySatisfy({ $0.source == .onlineRegistration }) players().anySatisfy({ $0.source == .onlineRegistration })
} }
func isOutOfTournament() -> Bool { func isOutOfTournament() -> Bool {
walkOut || unregistered walkOut
} }
init(tournament: String, groupStage: String? = nil, registrationDate: Date? = nil, callDate: Date? = nil, bracketPosition: Int? = nil, groupStagePosition: Int? = nil, comment: String? = nil, source: String? = nil, sourceValue: String? = nil, logo: String? = nil, name: String? = nil, walkOut: Bool = false, wildCardBracket: Bool = false, wildCardGroupStage: Bool = false, weight: Int = 0, lockedWeight: Int? = nil, confirmationDate: Date? = nil, qualified: Bool = false, finalRanking: Int? = nil, pointsEarned: Int? = nil, unregistered: Bool = false, unregistrationDate: Date? = nil) { init(tournament: String, groupStage: String? = nil, registrationDate: Date? = nil, callDate: Date? = nil, bracketPosition: Int? = nil, groupStagePosition: Int? = nil, comment: String? = nil, source: String? = nil, sourceValue: String? = nil, logo: String? = nil, name: String? = nil, walkOut: Bool = false, wildCardBracket: Bool = false, wildCardGroupStage: Bool = false, weight: Int = 0, lockedWeight: Int? = nil, confirmationDate: Date? = nil, qualified: Bool = false, finalRanking: Int? = nil, pointsEarned: Int? = nil) {
self.tournament = tournament self.tournament = tournament
self.groupStage = groupStage self.groupStage = groupStage
self.registrationDate = registrationDate ?? Date() self.registrationDate = registrationDate ?? Date()
@ -75,8 +68,6 @@ final class TeamRegistration: ModelObject, Storable {
self.qualified = qualified self.qualified = qualified
self.finalRanking = finalRanking self.finalRanking = finalRanking
self.pointsEarned = pointsEarned self.pointsEarned = pointsEarned
self.unregistered = unregistered
self.unregistrationDate = unregistrationDate
} }
var tournamentStore: TournamentStore { var tournamentStore: TournamentStore {
@ -333,7 +324,6 @@ final class TeamRegistration: ModelObject, Storable {
} }
func initialRoundColor() -> Color? { func initialRoundColor() -> Color? {
if unregistered { return Color.black }
if walkOut { return Color.logoRed } if walkOut { return Color.logoRed }
if groupStagePosition != nil { return Color.blue } if groupStagePosition != nil { return Color.blue }
if let initialRound = initialRound(), let colorHex = RoundRule.colors[safe: initialRound.index] { if let initialRound = initialRound(), let colorHex = RoundRule.colors[safe: initialRound.index] {
@ -640,8 +630,6 @@ final class TeamRegistration: ModelObject, Storable {
case _qualified = "qualified" case _qualified = "qualified"
case _finalRanking = "finalRanking" case _finalRanking = "finalRanking"
case _pointsEarned = "pointsEarned" case _pointsEarned = "pointsEarned"
case _unregistered = "unregistered"
case _unregistrationDate = "unregistrationDate"
} }
init(from decoder: Decoder) throws { init(from decoder: Decoder) throws {
@ -654,7 +642,6 @@ final class TeamRegistration: ModelObject, Storable {
wildCardGroupStage = try container.decodeIfPresent(Bool.self, forKey: ._wildCardGroupStage) ?? false wildCardGroupStage = try container.decodeIfPresent(Bool.self, forKey: ._wildCardGroupStage) ?? false
weight = try container.decodeIfPresent(Int.self, forKey: ._weight) ?? 0 weight = try container.decodeIfPresent(Int.self, forKey: ._weight) ?? 0
qualified = try container.decodeIfPresent(Bool.self, forKey: ._qualified) ?? false qualified = try container.decodeIfPresent(Bool.self, forKey: ._qualified) ?? false
unregistered = try container.decodeIfPresent(Bool.self, forKey: ._unregistered) ?? false
// Optional properties // Optional properties
groupStage = try container.decodeIfPresent(String.self, forKey: ._groupStage) groupStage = try container.decodeIfPresent(String.self, forKey: ._groupStage)
@ -671,7 +658,6 @@ final class TeamRegistration: ModelObject, Storable {
confirmationDate = try container.decodeIfPresent(Date.self, forKey: ._confirmationDate) confirmationDate = try container.decodeIfPresent(Date.self, forKey: ._confirmationDate)
finalRanking = try container.decodeIfPresent(Int.self, forKey: ._finalRanking) finalRanking = try container.decodeIfPresent(Int.self, forKey: ._finalRanking)
pointsEarned = try container.decodeIfPresent(Int.self, forKey: ._pointsEarned) pointsEarned = try container.decodeIfPresent(Int.self, forKey: ._pointsEarned)
unregistrationDate = try container.decodeIfPresent(Date.self, forKey: ._unregistrationDate)
} }
func encode(to encoder: Encoder) throws { func encode(to encoder: Encoder) throws {
@ -698,8 +684,6 @@ final class TeamRegistration: ModelObject, Storable {
try container.encode(qualified, forKey: ._qualified) try container.encode(qualified, forKey: ._qualified)
try container.encode(finalRanking, forKey: ._finalRanking) try container.encode(finalRanking, forKey: ._finalRanking)
try container.encode(pointsEarned, forKey: ._pointsEarned) try container.encode(pointsEarned, forKey: ._pointsEarned)
try container.encode(unregistered, forKey: ._unregistered)
try container.encode(unregistrationDate, forKey: ._unregistrationDate)
} }
func insertOnServer() { func insertOnServer() {

@ -94,34 +94,6 @@ struct EditingTeamView: View {
} }
} }
Toggle(isOn: .init(get: {
return team.unregistered
}, set: { value in
team.resetPositions()
team.wildCardGroupStage = false
team.walkOut = false
team.wildCardBracket = false
team.unregistered = value
if value {
team.unregistrationDate = Date()
} else {
team.unregistered = false
team.unregistrationDate = nil
team.registrationDate = Date()
}
do {
try tournamentStore.teamRegistrations.addOrUpdate(instance: team)
} catch {
Logger.error(error)
}
})) {
Text("Annulation")
if let unregisterDate = team.unregistrationDate {
Text(unregisterDate.localizedDate())
}
}
Toggle(isOn: .init(get: { Toggle(isOn: .init(get: {
return team.wildCardBracket return team.wildCardBracket
}, set: { value in }, set: { value in

@ -79,7 +79,6 @@ struct InscriptionManagerView: View {
case registeredOnline case registeredOnline
case walkOut case walkOut
case waiting case waiting
case unregistered
case bracket case bracket
case groupStage case groupStage
case wildcardGroupStage case wildcardGroupStage
@ -108,8 +107,6 @@ struct InscriptionManagerView: View {
return "Vous n'avez placé aucune équipe en poule." return "Vous n'avez placé aucune équipe en poule."
case .notImported: case .notImported:
return "Vous n'avez aucune équipe non importé. Elles proviennent toutes du fichier." return "Vous n'avez aucune équipe non importé. Elles proviennent toutes du fichier."
case .unregistered:
return "Vous n'avez aucune équipe ayant annulé une inscription."
} }
} }
@ -135,8 +132,6 @@ struct InscriptionManagerView: View {
return "Aucune équipe en poule" return "Aucune équipe en poule"
case .notImported: case .notImported:
return "Aucune équipe non importée" return "Aucune équipe non importée"
case .unregistered:
return "Aucune équipe ayant annulé"
} }
} }
@ -162,8 +157,6 @@ struct InscriptionManagerView: View {
return displayStyle == .wide ? "Liste d'attente" : "attente" return displayStyle == .wide ? "Liste d'attente" : "attente"
case .notImported: case .notImported:
return "Non importées" return "Non importées"
case .unregistered:
return displayStyle == .wide ? "Retirées" : "retirées"
} }
} }
} }
@ -512,8 +505,6 @@ struct InscriptionManagerView: View {
teams = teams.filter({ $0.inGroupStage() }) teams = teams.filter({ $0.inGroupStage() })
case .notImported: case .notImported:
teams = teams.filter({ $0.isImported() == false }) teams = teams.filter({ $0.isImported() == false })
case .unregistered:
teams = teams.filter({ $0.hasUnregistered() == true })
case .registeredLocally: case .registeredLocally:
teams = teams.filter({ $0.hasRegisteredOnline() == false }) teams = teams.filter({ $0.hasRegisteredOnline() == false })
case .registeredOnline: case .registeredOnline:
@ -739,9 +730,6 @@ struct InscriptionManagerView: View {
case .notImported: case .notImported:
let notImported: Int = max(0, sortedTeams.filter({ $0.isImported() == false }).count) let notImported: Int = max(0, sortedTeams.filter({ $0.isImported() == false }).count)
return notImported.formatted() return notImported.formatted()
case .unregistered:
let unregistered: Int = max(0, sortedTeams.filter({ $0.hasUnregistered() }).count)
return unregistered.formatted()
case .registeredLocally: case .registeredLocally:
let registeredLocally: Int = max(0, sortedTeams.filter({ $0.hasRegisteredOnline() == false }).count) let registeredLocally: Int = max(0, sortedTeams.filter({ $0.hasRegisteredOnline() == false }).count)
return registeredLocally.formatted() return registeredLocally.formatted()

@ -208,7 +208,7 @@ final class ServerDataTests: XCTestCase {
return return
} }
let teamRegistration = TeamRegistration(tournament: tournamentId, groupStage: groupStageId, registrationDate: Date(), callDate: Date(), bracketPosition: 1, groupStagePosition: 2, comment: "comment", source: "source", sourceValue: "source V", logo: "logo", name: "Stax", walkOut: true, wildCardBracket: true, wildCardGroupStage: true, weight: 1, lockedWeight: 11, confirmationDate: Date(), qualified: true, finalRanking: 4, pointsEarned: 200, unregistered: true, unregistrationDate: Date()) let teamRegistration = TeamRegistration(tournament: tournamentId, groupStage: groupStageId, registrationDate: Date(), callDate: Date(), bracketPosition: 1, groupStagePosition: 2, comment: "comment", source: "source", sourceValue: "source V", logo: "logo", name: "Stax", walkOut: true, wildCardBracket: true, wildCardGroupStage: true, weight: 1, lockedWeight: 11, confirmationDate: Date(), qualified: true, finalRanking: 4, pointsEarned: 200)
let tr: TeamRegistration = try await StoreCenter.main.service().post(teamRegistration) let tr: TeamRegistration = try await StoreCenter.main.service().post(teamRegistration)
@ -232,8 +232,6 @@ final class ServerDataTests: XCTestCase {
assert(tr.qualified == teamRegistration.qualified) assert(tr.qualified == teamRegistration.qualified)
assert(tr.finalRanking == teamRegistration.finalRanking) assert(tr.finalRanking == teamRegistration.finalRanking)
assert(tr.pointsEarned == teamRegistration.pointsEarned) assert(tr.pointsEarned == teamRegistration.pointsEarned)
assert(tr.unregistered == teamRegistration.unregistered)
assert(tr.unregistrationDate?.formatted() == teamRegistration.unregistrationDate?.formatted())
} }
func testPlayerRegistration() async throws { func testPlayerRegistration() async throws {

Loading…
Cancel
Save