|
|
|
|
@ -385,16 +385,10 @@ final class MatchScheduler : ModelObject, Storable { |
|
|
|
|
print("Targeted start date is after the minimum possible end date, returning true.") |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if targetedStartDate == minimumTargetedEndDate { |
|
|
|
|
print("Updating minimumTargetedEndDate to minimumPossibleEndDate: \(minimumPossibleEndDate)") |
|
|
|
|
minimumTargetedEndDate = minimumPossibleEndDate |
|
|
|
|
} else { |
|
|
|
|
print("Setting minimumTargetedEndDate to the earlier of \(minimumPossibleEndDate) and \(minimumTargetedEndDate)") |
|
|
|
|
minimumTargetedEndDate = min(minimumPossibleEndDate, minimumTargetedEndDate) |
|
|
|
|
} |
|
|
|
|
print("Targeted start date is before the minimum possible end date, returning false.") |
|
|
|
|
return false |
|
|
|
|
minimumTargetedEndDate = minimumPossibleEndDate |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -463,7 +457,7 @@ final class MatchScheduler : ModelObject, Storable { |
|
|
|
|
var courts = initialCourts ?? Array(courtsAvailable) |
|
|
|
|
var shouldStartAtDispatcherDate = rotationIndex > 0 |
|
|
|
|
|
|
|
|
|
while !availableMatchs.isEmpty && !issueFound && rotationIndex < 100 { |
|
|
|
|
while !availableMatchs.isEmpty && !issueFound && rotationIndex < 50 { |
|
|
|
|
freeCourtPerRotation[rotationIndex] = [] |
|
|
|
|
let previousRotationSlots = slots.filter({ $0.rotationIndex == rotationIndex - 1 }) |
|
|
|
|
var rotationStartDate: Date = getNextStartDate(fromPreviousRotationSlots: previousRotationSlots, includeBreakTime: false) ?? dispatcherStartDate |
|
|
|
|
@ -604,7 +598,9 @@ final class MatchScheduler : ModelObject, Storable { |
|
|
|
|
|
|
|
|
|
if shouldTryToFillUpCourtsAvailable == false { |
|
|
|
|
if roundObject.parent == nil && roundObject.index > 1 && indexInRound == 0, let nextMatch = match.next() { |
|
|
|
|
if courtPosition < courts.count - 1 && canBePlayed && roundMatchCanBePlayed(nextMatch, roundObject: roundObject, slots: slots, rotationIndex: rotationIndex, targetedStartDate: rotationStartDate, minimumTargetedEndDate: &minimumTargetedEndDate) { |
|
|
|
|
|
|
|
|
|
var nextMinimumTargetedEndDate = minimumTargetedEndDate |
|
|
|
|
if courtPosition < courts.count - 1 && canBePlayed && roundMatchCanBePlayed(nextMatch, roundObject: roundObject, slots: slots, rotationIndex: rotationIndex, targetedStartDate: rotationStartDate, minimumTargetedEndDate: &nextMinimumTargetedEndDate) { |
|
|
|
|
print("Returning true: Both current \(match.index) and next match \(nextMatch.index) can be played in rotation \(rotationIndex).") |
|
|
|
|
return true |
|
|
|
|
} else { |
|
|
|
|
@ -625,7 +621,7 @@ final class MatchScheduler : ModelObject, Storable { |
|
|
|
|
matchID: firstMatch.id, |
|
|
|
|
rotationIndex: rotationIndex, |
|
|
|
|
courtIndex: courtIndex, |
|
|
|
|
startDate: rotationStartDate, |
|
|
|
|
startDate: minimumTargetedEndDate, |
|
|
|
|
durationLeft: firstMatch.matchFormat.getEstimatedDuration(additionalEstimationDuration), |
|
|
|
|
minimumBreakTime: firstMatch.matchFormat.breakTime.breakTime |
|
|
|
|
) |
|
|
|
|
|