diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2025-12-29 00:41:52 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-12-29 00:41:52 +0100 |
| commit | a304c24b32c0327436bbd8c2853e60668e161b42 (patch) | |
| tree | 08f65c05daca134cf4d2e4f779bd15d98fd66370 /src/Costasdev.Busurbano.Backend/Services/Providers/RenfeTransitProvider.cs | |
| parent | 120a3c6bddd0fb8d9fa05df4763596956554c025 (diff) | |
Rename a lot of stuff, add Santiago real time
Diffstat (limited to 'src/Costasdev.Busurbano.Backend/Services/Providers/RenfeTransitProvider.cs')
| -rw-r--r-- | src/Costasdev.Busurbano.Backend/Services/Providers/RenfeTransitProvider.cs | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/src/Costasdev.Busurbano.Backend/Services/Providers/RenfeTransitProvider.cs b/src/Costasdev.Busurbano.Backend/Services/Providers/RenfeTransitProvider.cs deleted file mode 100644 index 1793ada..0000000 --- a/src/Costasdev.Busurbano.Backend/Services/Providers/RenfeTransitProvider.cs +++ /dev/null @@ -1,78 +0,0 @@ -using Costasdev.Busurbano.Backend.Configuration; -using Costasdev.Busurbano.Backend.Extensions; -using Costasdev.Busurbano.Backend.Types; -using Microsoft.Extensions.Options; -using SysFile = System.IO.File; - -namespace Costasdev.Busurbano.Backend.Services.Providers; - -[Obsolete] -public class RenfeTransitProvider : ITransitProvider -{ - private readonly AppConfiguration _configuration; - private readonly ILogger<RenfeTransitProvider> _logger; - - public RenfeTransitProvider(IOptions<AppConfiguration> options, ILogger<RenfeTransitProvider> logger) - { - _configuration = options.Value; - _logger = logger; - } - - public async Task<List<ConsolidatedCirculation>> GetCirculationsAsync(string stopId, DateTime nowLocal) - { - var todayDate = nowLocal.Date.ToString("yyyy-MM-dd"); - var stopArrivals = await LoadStopArrivalsProto(stopId, todayDate); - - 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<ConsolidatedCirculation>(); - - 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; - } - - private async Task<StopArrivals?> LoadStopArrivalsProto(string stopId, string dateString) - { - var file = Path.Combine(_configuration.RenfeScheduleBasePath, dateString, stopId + ".pb"); - if (!SysFile.Exists(file)) - { - _logger.LogWarning("Stop arrivals proto file not found: {File}", file); - return null; - } - - var contents = await SysFile.ReadAllBytesAsync(file); - var stopArrivals = StopArrivals.Parser.ParseFrom(contents); - return stopArrivals; - } -} |
