From a304c24b32c0327436bbd8c2853e60668e161b42 Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero Date: Mon, 29 Dec 2025 00:41:52 +0100 Subject: Rename a lot of stuff, add Santiago real time --- .../Services/Providers/RenfeTransitProvider.cs | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/Enmarcha.Backend/Services/Providers/RenfeTransitProvider.cs (limited to 'src/Enmarcha.Backend/Services/Providers/RenfeTransitProvider.cs') diff --git a/src/Enmarcha.Backend/Services/Providers/RenfeTransitProvider.cs b/src/Enmarcha.Backend/Services/Providers/RenfeTransitProvider.cs new file mode 100644 index 0000000..036c9b1 --- /dev/null +++ b/src/Enmarcha.Backend/Services/Providers/RenfeTransitProvider.cs @@ -0,0 +1,64 @@ +using Enmarcha.Backend.Extensions; +using Enmarcha.Backend.Configuration; +using Enmarcha.Backend.Types; +using Microsoft.Extensions.Options; +using SysFile = System.IO.File; + +namespace Enmarcha.Backend.Services.Providers; + +[Obsolete] +public class RenfeTransitProvider : ITransitProvider +{ + private readonly AppConfiguration _configuration; + private readonly ILogger _logger; + + public RenfeTransitProvider(IOptions options, ILogger logger) + { + _configuration = options.Value; + _logger = logger; + } + + public async Task> GetCirculationsAsync(string stopId, DateTime nowLocal) + { + var todayDate = nowLocal.Date.ToString("yyyy-MM-dd"); + StopArrivals stopArrivals = null!; + + if (stopArrivals == null) + { + return []; + } + + var now = nowLocal.AddSeconds(60 - nowLocal.Second); + var scopeEnd = now.AddMinutes(8 * 60); + + var scheduledWindow = stopArrivals.Arrivals + .Where(c => c.CallingDateTime(nowLocal.Date) != null) + .Where(c => c.CallingDateTime(nowLocal.Date)!.Value >= now && c.CallingDateTime(nowLocal.Date)!.Value <= scopeEnd) + .OrderBy(c => c.CallingDateTime(nowLocal.Date)!.Value); + + var consolidatedCirculations = new List(); + + foreach (var sched in scheduledWindow) + { + var minutes = (int)(sched.CallingDateTime(nowLocal.Date)!.Value - now).TotalMinutes; + + consolidatedCirculations.Add(new ConsolidatedCirculation + { + Line = sched.Line, + Route = sched.Route, + Schedule = new ScheduleData + { + Running = sched.StartingDateTime(nowLocal.Date)!.Value <= now, + Minutes = minutes, + TripId = sched.ServiceId[(sched.ServiceId.Length - 6)..(sched.ServiceId.Length - 1)], + ServiceId = sched.ServiceId[(sched.ServiceId.Length - 6)..(sched.ServiceId.Length - 1)], + ShapeId = sched.ShapeId, + }, + RealTime = null, + NextStreets = [.. sched.NextStreets] + }); + } + + return consolidatedCirculations; + } +} -- cgit v1.3