From 757960525576038898d655b630cbaac44671f599 Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero Date: Sun, 22 Mar 2026 13:20:00 +0100 Subject: Add nextstopprocessing to Lugo, fix deleted stops breaking home page --- .../Controllers/ArrivalsController.cs | 19 ++++++++++++------- .../Services/Processors/NextStopsProcessor.cs | 2 +- .../Queries/StopsInfo.cs | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/Enmarcha.Backend/Controllers/ArrivalsController.cs b/src/Enmarcha.Backend/Controllers/ArrivalsController.cs index 9216004..16bc047 100644 --- a/src/Enmarcha.Backend/Controllers/ArrivalsController.cs +++ b/src/Enmarcha.Backend/Controllers/ArrivalsController.cs @@ -243,11 +243,13 @@ public partial class ArrivalsController : ControllerBase var stopIds = ids.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); var requestContent = StopsInfoContent.Query(new StopsInfoContent.Args(stopIds)); - var request = new HttpRequestMessage(HttpMethod.Post, $"{_config.OpenTripPlannerBaseUrl}/gtfs/v1"); - request.Content = JsonContent.Create(new GraphClientRequest + var request = new HttpRequestMessage(HttpMethod.Post, $"{_config.OpenTripPlannerBaseUrl}/gtfs/v1") { - Query = requestContent - }); + Content = JsonContent.Create(new GraphClientRequest + { + Query = requestContent + }) + }; var response = await _httpClient.SendAsync(request); var responseBody = await response.Content.ReadFromJsonAsync>(); @@ -257,11 +259,14 @@ public partial class ArrivalsController : ControllerBase return StatusCode(500, "Error fetching stops data"); } - var result = responseBody.Data.Stops.ToDictionary( - s => s.GtfsId, + // TODO: Remove stops that are null, since that means the feed publisher deleted them. + var result = responseBody.Data.Stops + .Where(s => s != null) + .ToDictionary( + s => s!.GtfsId, s => { - var feedId = s.GtfsId.Split(':', 2)[0]; + var feedId = s!.GtfsId.Split(':', 2)[0]; var (fallbackColor, _) = _feedService.GetFallbackColourForFeed(feedId); return new diff --git a/src/Enmarcha.Backend/Services/Processors/NextStopsProcessor.cs b/src/Enmarcha.Backend/Services/Processors/NextStopsProcessor.cs index 6a76fe3..517faae 100644 --- a/src/Enmarcha.Backend/Services/Processors/NextStopsProcessor.cs +++ b/src/Enmarcha.Backend/Services/Processors/NextStopsProcessor.cs @@ -54,7 +54,7 @@ public class NextStopsProcessor : IArrivalsProcessor { if (nextStops.Count == 0) return null; - if (feedId is "vitrasa" or "tranvias" or "tussa" or "ourense") + if (feedId is "vitrasa" or "tranvias" or "tussa" or "ourense" or "lugo") { var streets = nextStops .Select(FeedService.GetStreetName) diff --git a/src/Enmarcha.Sources.OpenTripPlannerGql/Queries/StopsInfo.cs b/src/Enmarcha.Sources.OpenTripPlannerGql/Queries/StopsInfo.cs index f95de15..13d3704 100644 --- a/src/Enmarcha.Sources.OpenTripPlannerGql/Queries/StopsInfo.cs +++ b/src/Enmarcha.Sources.OpenTripPlannerGql/Queries/StopsInfo.cs @@ -32,7 +32,7 @@ public class StopsInfoContent : IGraphRequest public class StopsInfoResponse : AbstractGraphResponse { - [JsonPropertyName("stops")] public List? Stops { get; set; } + [JsonPropertyName("stops")] public List? Stops { get; set; } public class StopItem { -- cgit v1.3