Don't return departures with negative countdown
All checks were successful
Build image / build-image (push) Successful in 3m23s

This commit is contained in:
Paul Brinkmeier 2025-04-24 20:12:27 +02:00
parent cf7bb96517
commit 16f7d80677
2 changed files with 7 additions and 5 deletions

View File

@ -16,7 +16,7 @@
vrnp-static = pkgs.buildGoModule {
pname = "vrnp";
version = "0.0.4";
version = "0.0.5";
vendorHash = null;
# For building the package, we use only the files not ignored by Git as inputs.

10
main.go
View File

@ -117,6 +117,12 @@ func ParseDepartures(response DMResponse, allowedPlatform *string) (Departures,
return Departures{}, errors.New("could not parse countdown")
}
matchesPlatform := allowedPlatform == nil || d.Platform == *allowedPlatform
isInThePast := countdown < 0
if !matchesPlatform || isInThePast {
continue
}
if countdown == 0 {
leaving = "sofort"
}
@ -128,10 +134,6 @@ func ParseDepartures(response DMResponse, allowedPlatform *string) (Departures,
leaving = fmt.Sprintf("%02s:%02s", dt.Hour, dt.Minute)
}
if allowedPlatform != nil && d.Platform != *allowedPlatform {
continue
}
ds = append(ds, Departure{
d.Platform,
d.ServingLine.Symbol,