aboutsummaryrefslogtreecommitdiff
path: root/src/Costasdev.Busurbano.Backend/GraphClient/App
diff options
context:
space:
mode:
authorAriel Costas Guerrero <ariel@costas.dev>2025-12-23 12:59:52 +0100
committerAriel Costas Guerrero <ariel@costas.dev>2025-12-23 13:00:16 +0100
commit87417c313b455ba0dee19708528cc8d0b830a276 (patch)
tree34b7a2d6bb97157a1d35f57be85b8ff6532865d2 /src/Costasdev.Busurbano.Backend/GraphClient/App
parentbed48c3d7e49b1736d50ce42d92bb6c18cf02504 (diff)
Reimplement real time for Vitrasa
Diffstat (limited to 'src/Costasdev.Busurbano.Backend/GraphClient/App')
-rw-r--r--src/Costasdev.Busurbano.Backend/GraphClient/App/ArrivalsAtStop.cs52
1 files changed, 41 insertions, 11 deletions
diff --git a/src/Costasdev.Busurbano.Backend/GraphClient/App/ArrivalsAtStop.cs b/src/Costasdev.Busurbano.Backend/GraphClient/App/ArrivalsAtStop.cs
index 2c34784..cf2907c 100644
--- a/src/Costasdev.Busurbano.Backend/GraphClient/App/ArrivalsAtStop.cs
+++ b/src/Costasdev.Busurbano.Backend/GraphClient/App/ArrivalsAtStop.cs
@@ -5,28 +5,25 @@ namespace Costasdev.Busurbano.Backend.GraphClient.App;
public class ArrivalsAtStopContent : IGraphRequest<ArrivalsAtStopContent.Args>
{
- public const int PastArrivalMinutesIncluded = -15;
+ public const int PastArrivalMinutesIncluded = -75;
- public record Args(string Id, int DepartureCount, bool PastArrivals);
+ public record Args(string Id, bool Reduced);
public static string Query(Args args)
{
- var startTime = DateTimeOffset.Now;
- if (args.PastArrivals)
- {
- startTime = DateTimeOffset.Now.AddMinutes(PastArrivalMinutesIncluded);
- }
-
+ var startTime = DateTimeOffset.UtcNow.AddMinutes(PastArrivalMinutesIncluded);
var startTimeUnix = startTime.ToUnixTimeSeconds();
+ var geometryField = args.Reduced ? "" : @"tripGeometry { points }";
return string.Create(CultureInfo.InvariantCulture, $@"
query Query {{
stop(id:""{args.Id}"") {{
code
name
- arrivals: stoptimesWithoutPatterns(numberOfDepartures:{args.DepartureCount}, startTime: {startTimeUnix}) {{
+ arrivals: stoptimesWithoutPatterns(numberOfDepartures: 100, startTime: {startTimeUnix}, timeRange: 14400) {{
headsign
scheduledDeparture
+ serviceDay
pickupType
trip {{
@@ -36,10 +33,18 @@ public class ArrivalsAtStopContent : IGraphRequest<ArrivalsAtStopContent.Args>
route {{
color
textColor
+ longName
}}
departureStoptime {{
scheduledDeparture
}}
+ {geometryField}
+ stoptimes {{
+ stop {{
+ name
+ }}
+ scheduledDeparture
+ }}
}}
}}
}}
@@ -68,9 +73,12 @@ public class ArrivalsAtStopResponse : AbstractGraphResponse
[JsonPropertyName("scheduledDeparture")]
public int ScheduledDepartureSeconds { get; set; }
+ [JsonPropertyName("serviceDay")]
+ public long ServiceDay { get; set; }
+
[JsonPropertyName("pickupType")] public required string PickupTypeOriginal { get; set; }
- public PickupType PickupTypeParsed => PickupTypeParsed.Parse(PickupTypeOriginal);
+ public PickupType PickupTypeParsed => PickupType.Parse(PickupTypeOriginal);
[JsonPropertyName("trip")] public required TripDetails Trip { get; set; }
}
@@ -87,6 +95,26 @@ public class ArrivalsAtStopResponse : AbstractGraphResponse
public required DepartureStoptime DepartureStoptime { get; set; }
[JsonPropertyName("route")] public required RouteDetails Route { get; set; }
+
+ [JsonPropertyName("tripGeometry")] public GeometryDetails? Geometry { get; set; }
+
+ [JsonPropertyName("stoptimes")] public List<StoptimeDetails> Stoptimes { get; set; } = [];
+ }
+
+ public class GeometryDetails
+ {
+ [JsonPropertyName("points")] public string? Points { get; set; }
+ }
+
+ public class StoptimeDetails
+ {
+ [JsonPropertyName("stop")] public required StopDetails Stop { get; set; }
+ [JsonPropertyName("scheduledDeparture")] public int ScheduledDeparture { get; set; }
+ }
+
+ public class StopDetails
+ {
+ [JsonPropertyName("name")] public required string Name { get; set; }
}
public class DepartureStoptime
@@ -100,6 +128,8 @@ public class ArrivalsAtStopResponse : AbstractGraphResponse
[JsonPropertyName("color")] public string? Color { get; set; }
[JsonPropertyName("textColor")] public string? TextColor { get; set; }
+
+ [JsonPropertyName("longName")] public string? LongName { get; set; }
}
public class PickupType
@@ -111,7 +141,7 @@ public class ArrivalsAtStopResponse : AbstractGraphResponse
_value = value;
}
- public PickupType Parse(string value)
+ public static PickupType Parse(string value)
{
return value switch
{