diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2025-11-07 12:43:18 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-11-07 12:43:18 +0100 |
| commit | 4420def7411a053e930b44117e2bf63625d824dc (patch) | |
| tree | bfe02088318210fe2c9a2928d6afedc39cb88e45 /src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs | |
| parent | 86b922c1853110981d8df985a183cb43690c575d (diff) | |
Make "stops" page be the home (renaming only)
Diffstat (limited to 'src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs')
| -rw-r--r-- | src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs b/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs index 5b03b6d..2d35a4c 100644 --- a/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs +++ b/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs @@ -86,19 +86,19 @@ public class VigoController : ControllerBase return JsonSerializer.Deserialize<ScheduledStop[]>(contents)!; }*/ - [HttpGet("GetStopArrivalsMerged")] - public async Task<IActionResult> GetStopArrivalsMerged( + [HttpGet("GetConsolidatedCirculations")] + public async Task<IActionResult> GetConsolidatedCirculations( [FromQuery] int stopId ) { StringBuilder outputBuffer = new(); - // Use Europe/Madrid timezone consistently to avoid UTC/local skew - var tz = TimeZoneInfo.FindSystemTimeZoneById("Europe/Madrid"); - var nowLocal = TimeZoneInfo.ConvertTime(DateTime.UtcNow, tz); + // Use Europe/Madrid timezone consistently to avoid UTC/local skew + var tz = TimeZoneInfo.FindSystemTimeZoneById("Europe/Madrid"); + var nowLocal = TimeZoneInfo.ConvertTime(DateTime.UtcNow, tz); - var realtimeTask = _api.GetStopEstimates(stopId); - var timetableTask = LoadTimetable(stopId.ToString(), nowLocal.Date.ToString("yyyy-MM-dd")); + var realtimeTask = _api.GetStopEstimates(stopId); + var timetableTask = LoadTimetable(stopId.ToString(), nowLocal.Date.ToString("yyyy-MM-dd")); await Task.WhenAll(realtimeTask, timetableTask); @@ -108,14 +108,14 @@ public class VigoController : ControllerBase .Where(c => c.StartingDateTime() != null && c.CallingDateTime() != null) .ToList(); - var now = nowLocal.AddSeconds(60 - nowLocal.Second); + var now = nowLocal.AddSeconds(60 - nowLocal.Second); // Define the scope end as the time of the last realtime arrival (no extra buffer) var scopeEnd = realTimeEstimates.Count > 0 ? now.AddMinutes(realTimeEstimates.Max(e => e.Minutes)) : now; - List<ConsolidatedCirculation> consolidatedCirculations = []; - var usedTripIds = new HashSet<string>(); + List<ConsolidatedCirculation> consolidatedCirculations = []; + var usedTripIds = new HashSet<string>(); foreach (var estimate in realTimeEstimates) { @@ -256,6 +256,7 @@ public class VigoController : ControllerBase }); } } + // Sort by ETA (RealTime minutes if present; otherwise Schedule minutes) var sorted = consolidatedCirculations .OrderBy(c => c.RealTime?.Minutes ?? c.Schedule!.Minutes) |
