Skip to content

Commit

Permalink
fix: preserve stops with no route patterns (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
boringcactus authored Mar 27, 2024
1 parent fd65245 commit 562c0a2
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ data class NearbyStaticData(val data: List<RouteWithStops>) {
.map { patternId -> response.routePatterns.getValue(patternId) }
.groupBy { it.routeId }

if (newPatternsByRoute.isEmpty()) {
return@forEach
}

val stopKey =
stop.parentStationId?.let { parentStationId ->
fullStopIds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,53 @@ class NearbyResponseTest {
)
}

@Test
fun `byRouteAndStop preserves unscheduled physical platform`() {
val objects = ObjectCollectionBuilder()

val parentStation = objects.stop { id = "place-forhl" }

val logicalPlatform =
objects.stop {
id = "70001"
parentStationId = parentStation.id
}
val physicalPlatform =
objects.stop {
id = "Forest Hills-01"
parentStationId = parentStation.id
}

val route = objects.route { id = "Orange" }

val routePattern =
objects.routePattern(route) { representativeTrip { headsign = "Oak Grove" } }

val response =
StopAndRoutePatternResponse(
objects,
patternIdsByStop =
mapOf(
logicalPlatform.id to
listOf(
routePattern.id,
),
),
parentStops = mapOf(parentStation.id to parentStation),
)

assertEquals(
NearbyStaticData.build {
route(route) {
stop(parentStation, listOf(logicalPlatform.id, physicalPlatform.id)) {
headsign("Oak Grove", listOf(routePattern))
}
}
},
NearbyStaticData(response)
)
}

@Test
fun `withRealtimeInfo includes predictions filtered to the correct stop and pattern`() {
val objects = ObjectCollectionBuilder()
Expand Down

0 comments on commit 562c0a2

Please sign in to comment.