aboutsummaryrefslogtreecommitdiff
path: root/src/Costasdev.Busurbano.Backend/Controllers
diff options
context:
space:
mode:
authorCopilot <198982749+Copilot@users.noreply.github.com>2025-11-21 17:47:52 +0100
committerGitHub <noreply@github.com>2025-11-21 17:47:52 +0100
commit3af7ff6ecdf816849d45e094d20f1fa57a4c07cc (patch)
tree36fb12d2e518db4a24190faf66664e75f5182773 /src/Costasdev.Busurbano.Backend/Controllers
parent19c1bb796fc3dcc3d191d884e53107ee3598e972 (diff)
Remove schedule delay limit from bus matching algorithm (#109)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: arielcostas <94913521+arielcostas@users.noreply.github.com>
Diffstat (limited to 'src/Costasdev.Busurbano.Backend/Controllers')
-rw-r--r--src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs b/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs
index 12489ca..f3f3d69 100644
--- a/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs
+++ b/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs
@@ -210,11 +210,9 @@ public class VigoController : ControllerBase
// Matching strategy:
// 1) Prefer a started trip whose scheduled calling time is close to the estimated arrival.
// 2) If no good started match, pick the next not-started trip (soonest in the future).
- // 3) Reject matches where scheduled time is >10 minutes AFTER realtime (data inconsistency).
- // 4) Reject matches where the bus would arrive >3 minutes BEFORE schedule (too early).
- // 5) Fallbacks: if no future trips, use the best started one even if far.
+ // 3) Reject matches where the bus would arrive >3 minutes BEFORE schedule (too early).
+ // 4) Fallbacks: if no future trips, use the best started one even if far.
const int startedMatchToleranceMinutes = 15; // how close a started trip must be to consider it a match
- const int maxScheduleDelayMinutes = 10; // reject if scheduled is this much later than realtime
const int maxEarlyArrivalMinutes = 3; // reject if bus arrives more than 3 minutes before schedule
var startedCandidates = possibleCirculations
@@ -242,23 +240,17 @@ public class VigoController : ControllerBase
// Check best started candidate
if (bestStarted != null &&
bestStarted.AbsDiff <= startedMatchToleranceMinutes &&
- bestStarted.TimeDiff <= maxScheduleDelayMinutes && // reject if scheduled too far after realtime
bestStarted.TimeDiff >= -maxEarlyArrivalMinutes) // reject if bus arrives too early
{
closestCirculation = bestStarted.Circulation;
}
else if (futureCandidates.Count > 0)
{
- // Pick the soonest upcoming trip, but reject if it's scheduled too far after realtime
+ // Pick the soonest upcoming trip
var soonest = futureCandidates.First();
- if (soonest.TimeDiff <= maxScheduleDelayMinutes)
- {
- closestCirculation = soonest.Circulation;
- }
- // Otherwise, leave it null (no valid match)
+ closestCirculation = soonest.Circulation;
}
else if (bestStarted != null &&
- bestStarted.TimeDiff <= maxScheduleDelayMinutes &&
bestStarted.TimeDiff >= -maxEarlyArrivalMinutes)
{
// nothing upcoming today; fallback to the closest started one (if timing is reasonable)