Log and fix connection
This commit is contained in:
parent
5103aecacf
commit
0e8a2e735f
2 changed files with 6 additions and 7 deletions
|
|
@ -25,12 +25,8 @@ namespace ShiftScheduler.Services
|
||||||
|
|
||||||
if (apiResponse?.Connections.Count > 0)
|
if (apiResponse?.Connections.Count > 0)
|
||||||
{
|
{
|
||||||
var allConnections = apiResponse.Connections.Select(MapToTransportConnection).ToList();
|
var allConnections = apiResponse.Connections.Select(MapToTransportConnection).ToList();
|
||||||
|
allConnections.ForEach(tc => logger.LogDebug($"Found connection {tc}"));
|
||||||
foreach (var connection in allConnections)
|
|
||||||
{
|
|
||||||
logger.LogDebug($"Found connection {connection}");
|
|
||||||
}
|
|
||||||
|
|
||||||
var bestConnection = TransportConnectionCalculator.FindBestConnection(
|
var bestConnection = TransportConnectionCalculator.FindBestConnection(
|
||||||
allConnections, new ConnectionPickArgument(shiftStartTime, config.SafetyBufferMinutes, config.MaxEarlyArrivalMinutes, config.MaxLateArrivalMinutes), logger);
|
allConnections, new ConnectionPickArgument(shiftStartTime, config.SafetyBufferMinutes, config.MaxEarlyArrivalMinutes, config.MaxLateArrivalMinutes), logger);
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ public static class TransportConnectionCalculator
|
||||||
var bestValidConnection = validConnections.Last();
|
var bestValidConnection = validConnections.Last();
|
||||||
if (bestValidConnection.ArrivalTime > earliestAcceptableTime)
|
if (bestValidConnection.ArrivalTime > earliestAcceptableTime)
|
||||||
{
|
{
|
||||||
|
logger.LogDebug($"Found bestValidConnection {bestValidConnection}");
|
||||||
return bestValidConnection;
|
return bestValidConnection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -57,9 +58,11 @@ public static class TransportConnectionCalculator
|
||||||
// If no connections arrive before latest arrival time, check if any arrive within acceptable late range
|
// If no connections arrive before latest arrival time, check if any arrive within acceptable late range
|
||||||
if (lateValidConnections.Count > 0)
|
if (lateValidConnections.Count > 0)
|
||||||
{
|
{
|
||||||
|
logger.LogDebug($"Found lateValidConnection {lateValidConnections.First()}");
|
||||||
return lateValidConnections.First();
|
return lateValidConnections.First();
|
||||||
}
|
}
|
||||||
|
|
||||||
return validConnections.FirstOrDefault();
|
logger.LogDebug($"Use last valid connection {validConnections.LastOrDefault()}");
|
||||||
|
return validConnections.LastOrDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue