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: cancel trips with a boarding status of Canceled #364

Merged
merged 4 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
9 changes: 8 additions & 1 deletion lib/concentrate/parser/gtfs_realtime_enhanced.ex
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,19 @@ defmodule Concentrate.Parser.GTFSRealtimeEnhanced do

boarding_status = decode_boarding_status(Map.get(stu, "boarding_status"))

schedule_relationship =
if boarding_status == "Cancelled" do
:SKIPPED
else
schedule_relationship(Map.get(stu, "schedule_relationship"))
end

StopTimeUpdate.new(
trip_id:
if(descriptor = Map.get(trip_update, "trip"), do: Map.get(descriptor, "trip_id")),
stop_id: Map.get(stu, "stop_id"),
stop_sequence: Map.get(stu, "stop_sequence"),
schedule_relationship: schedule_relationship(Map.get(stu, "schedule_relationship")),
schedule_relationship: schedule_relationship,
arrival_time: arrival_time,
departure_time: departure_time,
passthrough_time: Map.get(stu, "passthrough_time"),
Expand Down
14 changes: 14 additions & 0 deletions test/concentrate/parser/gtfs_realtime_enhanced_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,20 @@ defmodule Concentrate.Parser.GTFSRealtimeEnhancedTest do
assert StopTimeUpdate.status(stop_update) == "UNIQUE STATUS"
end

test "handles cancelled status" do
update = %{
"trip" => %{},
"stop_time_update" => [
%{
"boarding_status" => "CANCELLED"
}
]
}

[_td, stop_update] = decode_trip_update(update, %Options{})
assert StopTimeUpdate.schedule_relationship(stop_update) == :SKIPPED
end

test "can handle platform id information" do
update = %{
"trip" => %{},
Expand Down
Loading