|
|
|
@ -494,22 +494,41 @@ class MatchScheduler { |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
if let roundId { |
|
|
|
// if let roundId { |
|
|
|
if let round : Round = Store.main.findById(roundId) { |
|
|
|
// if let round : Round = Store.main.findById(roundId) { |
|
|
|
let matches = round._matches() |
|
|
|
// let matches = round._matches().filter({ $0.disabled == false }).sorted(by: \.index) |
|
|
|
round.resetFromRoundAllMatchesStartDate() |
|
|
|
// round.resetFromRoundAllMatchesStartDate() |
|
|
|
flattenedMatches = matches + flattenedMatches |
|
|
|
// flattenedMatches = matches + flattenedMatches |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// } else if let matchId { |
|
|
|
|
|
|
|
// if let match : Match = Store.main.findById(matchId) { |
|
|
|
|
|
|
|
// if let round = match.roundObject { |
|
|
|
|
|
|
|
// round.resetFromRoundAllMatchesStartDate(from: match) |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// flattenedMatches = [match] + flattenedMatches |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if let roundId, let matchId { |
|
|
|
|
|
|
|
//todo |
|
|
|
|
|
|
|
if let index = flattenedMatches.firstIndex(where: { $0.round == roundId && $0.id == matchId }) { |
|
|
|
|
|
|
|
flattenedMatches[index...].forEach { |
|
|
|
|
|
|
|
$0.startDate = nil |
|
|
|
|
|
|
|
$0.removeCourt() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else if let roundId { |
|
|
|
} else if let matchId { |
|
|
|
//todo |
|
|
|
if let match : Match = Store.main.findById(matchId) { |
|
|
|
if let index = flattenedMatches.firstIndex(where: { $0.round == roundId }) { |
|
|
|
if let round = match.roundObject { |
|
|
|
flattenedMatches[index...].forEach { |
|
|
|
round.resetFromRoundAllMatchesStartDate(from: match) |
|
|
|
$0.startDate = nil |
|
|
|
|
|
|
|
$0.removeCourt() |
|
|
|
} |
|
|
|
} |
|
|
|
flattenedMatches = [match] + flattenedMatches |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let usedCourts = getAvailableCourts(from: allMatches.filter({ $0.startDate?.isEarlierThan(startDate) == true && $0.startDate?.dayInt == startDate.dayInt })) |
|
|
|
let usedCourts = getAvailableCourts(from: allMatches.filter({ $0.startDate?.isEarlierThan(startDate) == true && $0.startDate?.dayInt == startDate.dayInt })) |
|
|
|
let initialCourts = usedCourts.filter { (court, availableDate) in |
|
|
|
let initialCourts = usedCourts.filter { (court, availableDate) in |
|
|
|
availableDate <= startDate |
|
|
|
availableDate <= startDate |
|
|
|
|