Skip to content

Commit

Permalink
feat(UpcomingTrip): Only show BRD when <= 90 seconds (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
KaylaBrady authored Apr 12, 2024
1 parent 3338e4f commit 8588c37
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
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

0 comments on commit 8588c37

Please sign in to comment.