aboutsummaryrefslogtreecommitdiff
path: root/src/Costasdev.Busurbano.Backend/GraphClient/App/ArrivalsAtStop.cs
diff options
context:
space:
mode:
authorAriel Costas Guerrero <ariel@costas.dev>2025-12-22 22:06:06 +0100
committerAriel Costas Guerrero <ariel@costas.dev>2025-12-22 22:06:06 +0100
commitbed48c3d7e49b1736d50ce42d92bb6c18cf02504 (patch)
tree475571ad6fa8c7aa1f8e81520689bf1eb425164c /src/Costasdev.Busurbano.Backend/GraphClient/App/ArrivalsAtStop.cs
parent68f49dec91d68579803d6d579b1f1ecb4fc1dd1f (diff)
Refactor arrivals handling and improve type definitions; reorganise components
Diffstat (limited to 'src/Costasdev.Busurbano.Backend/GraphClient/App/ArrivalsAtStop.cs')
-rw-r--r--src/Costasdev.Busurbano.Backend/GraphClient/App/ArrivalsAtStop.cs20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/Costasdev.Busurbano.Backend/GraphClient/App/ArrivalsAtStop.cs b/src/Costasdev.Busurbano.Backend/GraphClient/App/ArrivalsAtStop.cs
index 53c1165..2c34784 100644
--- a/src/Costasdev.Busurbano.Backend/GraphClient/App/ArrivalsAtStop.cs
+++ b/src/Costasdev.Busurbano.Backend/GraphClient/App/ArrivalsAtStop.cs
@@ -5,16 +5,26 @@ namespace Costasdev.Busurbano.Backend.GraphClient.App;
public class ArrivalsAtStopContent : IGraphRequest<ArrivalsAtStopContent.Args>
{
- public record Args(string Id, int DepartureCount);
+ public const int PastArrivalMinutesIncluded = -15;
+
+ public record Args(string Id, int DepartureCount, bool PastArrivals);
public static string Query(Args args)
{
+ var startTime = DateTimeOffset.Now;
+ if (args.PastArrivals)
+ {
+ startTime = DateTimeOffset.Now.AddMinutes(PastArrivalMinutesIncluded);
+ }
+
+ var startTimeUnix = startTime.ToUnixTimeSeconds();
+
return string.Create(CultureInfo.InvariantCulture, $@"
query Query {{
stop(id:""{args.Id}"") {{
code
name
- arrivals: stoptimesWithoutPatterns(numberOfDepartures:{args.DepartureCount}) {{
+ arrivals: stoptimesWithoutPatterns(numberOfDepartures:{args.DepartureCount}, startTime: {startTimeUnix}) {{
headsign
scheduledDeparture
pickupType
@@ -40,7 +50,7 @@ public class ArrivalsAtStopContent : IGraphRequest<ArrivalsAtStopContent.Args>
public class ArrivalsAtStopResponse : AbstractGraphResponse
{
- [JsonPropertyName("stop")] public StopItem Stop { get; set; }
+ [JsonPropertyName("stop")] public required StopItem Stop { get; set; }
public class StopItem
{
@@ -87,9 +97,9 @@ public class ArrivalsAtStopResponse : AbstractGraphResponse
public class RouteDetails
{
- [JsonPropertyName("color")] public required string Color { get; set; }
+ [JsonPropertyName("color")] public string? Color { get; set; }
- [JsonPropertyName("textColor")] public required string TextColor { get; set; }
+ [JsonPropertyName("textColor")] public string? TextColor { get; set; }
}
public class PickupType