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 pointsEarned: Int?
var unregistered: Bool = false
var unregistrationDate: Date? = nil
func hasUnregistered() -> Bool {
unregistered
}
func hasRegisteredOnline() -> Bool {
players().anySatisfy({ $0.source == .onlineRegistration })
}
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.groupStage = groupStage
self.registrationDate = registrationDate ?? Date()
@ -75,8 +68,6 @@ final class TeamRegistration: ModelObject, Storable {
self.qualified = qualified
self.finalRanking = finalRanking
self.pointsEarned = pointsEarned
self.unregistered = unregistered
self.unregistrationDate = unregistrationDate
}
var tournamentStore: TournamentStore {
@ -333,7 +324,6 @@ final class TeamRegistration: ModelObject, Storable {
}
func initialRoundColor() -> Color? {
if unregistered { return Color.black }
if walkOut { return Color.logoRed }
if groupStagePosition != nil { return Color.blue }
if let initialRound = initialRound(), let colorHex = RoundRule.colors[safe: initialRound.index] {
@ -640,8 +630,6 @@ final class TeamRegistration: ModelObject, Storable {
case _qualified = "qualified"
case _finalRanking = "finalRanking"
case _pointsEarned = "pointsEarned"
case _unregistered = "unregistered"
case _unregistrationDate = "unregistrationDate"
}
init(from decoder: Decoder) throws {
@ -654,7 +642,6 @@ final class TeamRegistration: ModelObject, Storable {
wildCardGroupStage = try container.decodeIfPresent(Bool.self, forKey: ._wildCardGroupStage) ?? false
weight = try container.decodeIfPresent(Int.self, forKey: ._weight) ?? 0
qualified = try container.decodeIfPresent(Bool.self, forKey: ._qualified) ?? false
unregistered = try container.decodeIfPresent(Bool.self, forKey: ._unregistered) ?? false
// Optional properties
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)
finalRanking = try container.decodeIfPresent(Int.self, forKey: ._finalRanking)
pointsEarned = try container.decodeIfPresent(Int.self, forKey: ._pointsEarned)
unregistrationDate = try container.decodeIfPresent(Date.self, forKey: ._unregistrationDate)
}
func encode(to encoder: Encoder) throws {
@ -698,8 +684,6 @@ final class TeamRegistration: ModelObject, Storable {
try container.encode(qualified, forKey: ._qualified)
try container.encode(finalRanking, forKey: ._finalRanking)
try container.encode(pointsEarned, forKey: ._pointsEarned)
try container.encode(unregistered, forKey: ._unregistered)
try container.encode(unregistrationDate, forKey: ._unregistrationDate)
}
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: {
return team.wildCardBracket
}, set: { value in

@ -79,7 +79,6 @@ struct InscriptionManagerView: View {
case registeredOnline
case walkOut
case waiting
case unregistered
case bracket
case groupStage
case wildcardGroupStage
@ -108,8 +107,6 @@ struct InscriptionManagerView: View {
return "Vous n'avez placé aucune équipe en poule."
case .notImported:
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"
case .notImported:
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"
case .notImported:
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() })
case .notImported:
teams = teams.filter({ $0.isImported() == false })
case .unregistered:
teams = teams.filter({ $0.hasUnregistered() == true })
case .registeredLocally:
teams = teams.filter({ $0.hasRegisteredOnline() == false })
case .registeredOnline:
@ -739,9 +730,6 @@ struct InscriptionManagerView: View {
case .notImported:
let notImported: Int = max(0, sortedTeams.filter({ $0.isImported() == false }).count)
return notImported.formatted()
case .unregistered:
let unregistered: Int = max(0, sortedTeams.filter({ $0.hasUnregistered() }).count)
return unregistered.formatted()
case .registeredLocally:
let registeredLocally: Int = max(0, sortedTeams.filter({ $0.hasRegisteredOnline() == false }).count)
return registeredLocally.formatted()

@ -208,7 +208,7 @@ final class ServerDataTests: XCTestCase {
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)
@ -232,8 +232,6 @@ final class ServerDataTests: XCTestCase {
assert(tr.qualified == teamRegistration.qualified)
assert(tr.finalRanking == teamRegistration.finalRanking)
assert(tr.pointsEarned == teamRegistration.pointsEarned)
assert(tr.unregistered == teamRegistration.unregistered)
assert(tr.unregistrationDate?.formatted() == teamRegistration.unregistrationDate?.formatted())
}
func testPlayerRegistration() async throws {

Loading…
Cancel
Save