Skip to content

Commit

Permalink
add last_trip field to TripUpdates enhanced feed
Browse files Browse the repository at this point in the history
  • Loading branch information
bfauble committed Mar 27, 2024
1 parent d24f53d commit b9108b7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/concentrate/encoder/trip_updates_enhanced.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ defmodule Concentrate.Encoder.TripUpdatesEnhanced do
defp enhanced_data(update) do
%{
route_pattern_id: TripDescriptor.route_pattern_id(update),
revenue: TripDescriptor.revenue(update)
revenue: TripDescriptor.revenue(update),
last_trip: TripDescriptor.last_trip(update)
}
end

Expand Down
40 changes: 38 additions & 2 deletions test/concentrate/encoder/trip_updates_enhanced_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ defmodule Concentrate.Encoder.TripUpdatesEnhancedTest do
%{
"trip_update" => %{
"trip" => %{
"route_pattern_id" => "pattern"
"route_pattern_id" => "pattern",
"last_trip" => false
}
}
}
Expand Down Expand Up @@ -153,7 +154,42 @@ defmodule Concentrate.Encoder.TripUpdatesEnhancedTest do
"direction_id" => 0,
"revenue" => false,
"route_id" => "route",
"trip_id" => "NONREV-trip"
"trip_id" => "NONREV-trip",
"last_trip" => false
}
}
}
]
} = encoded
end

test "last_trip field is included" do
parsed = [
TripDescriptor.new(
trip_id: "trip",
route_id: "route",
direction_id: 0,
last_trip: true
),
StopTimeUpdate.new(
trip_id: "trip",
stop_id: "stop"
)
]

encoded = Jason.decode!(encode_groups(group(parsed)))

assert %{
"entity" => [
%{
"id" => "trip",
"trip_update" => %{
"trip" => %{
"direction_id" => 0,
"revenue" => true,
"route_id" => "route",
"trip_id" => "trip",
"last_trip" => true
}
}
}
Expand Down

0 comments on commit b9108b7

Please sign in to comment.