From 64f5ae0e377c21d9c153c7615aee45ff7734cbb4 Mon Sep 17 00:00:00 2001 From: KaylaBrady <31781298+KaylaBrady@users.noreply.github.com> Date: Thu, 11 Apr 2024 10:17:55 -0400 Subject: [PATCH] feat(UpcomingTrip): Only show BRD when <= 90 seconds --- .../com/mbta/tid/mbta_app/model/Prediction.kt | 1 + .../mbta/tid/mbta_app/model/UpcomingTrip.kt | 3 ++- .../tid/mbta_app/model/UpcomingTripTest.kt | 24 +++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/shared/src/commonMain/kotlin/com/mbta/tid/mbta_app/model/Prediction.kt b/shared/src/commonMain/kotlin/com/mbta/tid/mbta_app/model/Prediction.kt index f98bb9eb2..61f668437 100644 --- a/shared/src/commonMain/kotlin/com/mbta/tid/mbta_app/model/Prediction.kt +++ b/shared/src/commonMain/kotlin/com/mbta/tid/mbta_app/model/Prediction.kt @@ -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 diff --git a/shared/src/commonMain/kotlin/com/mbta/tid/mbta_app/model/UpcomingTrip.kt b/shared/src/commonMain/kotlin/com/mbta/tid/mbta_app/model/UpcomingTrip.kt index b92a11351..753f28834 100644 --- a/shared/src/commonMain/kotlin/com/mbta/tid/mbta_app/model/UpcomingTrip.kt +++ b/shared/src/commonMain/kotlin/com/mbta/tid/mbta_app/model/UpcomingTrip.kt @@ -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 } diff --git a/shared/src/commonTest/kotlin/com/mbta/tid/mbta_app/model/UpcomingTripTest.kt b/shared/src/commonTest/kotlin/com/mbta/tid/mbta_app/model/UpcomingTripTest.kt index 0abdedc61..36535af7e 100644 --- a/shared/src/commonTest/kotlin/com/mbta/tid/mbta_app/model/UpcomingTripTest.kt +++ b/shared/src/commonTest/kotlin/com/mbta/tid/mbta_app/model/UpcomingTripTest.kt @@ -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()