Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(UpcomingTrip): Only show BRD when <= 90 seconds #127

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import kotlinx.serialization.Serializable

val ARRIVAL_CUTOFF = 30.seconds
val APPROACH_CUTOFF = 60.seconds
val BOARDING_CUTOFF = 90.seconds
val DISTANT_FUTURE_CUTOFF = 60.minutes

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ data class UpcomingTrip(
if (
vehicle?.currentStatus == Vehicle.CurrentStatus.StoppedAt &&
vehicle.stopId == prediction.stopId &&
vehicle.tripId == prediction.tripId
vehicle.tripId == prediction.tripId &&
timeRemaining <= BOARDING_CUTOFF
) {
return Format.Boarding
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,30 @@ class UpcomingTripTest {
)
}

@Test
fun `not boarding when stopped at stop but more than 90 seconds until departure`() {
val now = Clock.System.now()
val vehicle = vehicle {
currentStatus = Vehicle.CurrentStatus.StoppedAt
stopId = "12345"
tripId = "trip1"
}
assertEquals(
Format.Minutes(2),
UpcomingTrip(
trip {},
prediction {
departureTime = now.plus(95.seconds)
stopId = "12345"
tripId = "trip1"
vehicleId = vehicle.id
},
vehicle
)
.format(now)
)
}

@Test
fun `not boarding`() {
val now = Clock.System.now()
Expand Down