From 4420def7411a053e930b44117e2bf63625d824dc Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero Date: Fri, 7 Nov 2025 12:43:18 +0100 Subject: Make "stops" page be the home (renaming only) --- .../Controllers/VigoController.cs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs') 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(contents)!; }*/ - [HttpGet("GetStopArrivalsMerged")] - public async Task GetStopArrivalsMerged( + [HttpGet("GetConsolidatedCirculations")] + public async Task 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 consolidatedCirculations = []; - var usedTripIds = new HashSet(); + List consolidatedCirculations = []; + var usedTripIds = new HashSet(); 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) -- cgit v1.3