-
Notifications
You must be signed in to change notification settings - Fork 18
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: use last predicted stop as added trip headsign #839
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -181,10 +181,15 @@ defmodule State.Trip.AddedTest do | |
{:ok, %{shape: shape, prediction: prediction}} | ||
end | ||
|
||
test "if there's a matching shape for the route/direction, uses the last stop from that shape", | ||
test "if there's a matching shape for the route/direction, uses the last stop predicted stop", | ||
%{prediction: prediction} do | ||
insert_predictions([prediction]) | ||
assert [%{headsign: "Last Stop on Shape"}] = by_id(@trip_id) | ||
predictions = [ | ||
%{@prediction | stop_sequence: 3, stop_id: "child"}, | ||
%{@prediction | stop_sequence: 2, stop_id: "other"} | ||
] | ||
|
||
insert_predictions(predictions) | ||
assert [%{headsign: "Parent"}] = by_id(@trip_id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it possible to add multiple predictions to verify that the headsign is being properly set for multiple predictions on the same trip? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test updated to use multiple predictions. There's also this test on for the route_pattern side that tests the same thing so this has us covering both the shape and route pattern sides of this functionality. |
||
end | ||
|
||
test "does not use a shape on the wrong route or direction", %{ | ||
|
@@ -231,13 +236,13 @@ defmodule State.Trip.AddedTest do | |
test "creates a trip with revenue value set to :REVENUE", | ||
%{prediction: prediction} do | ||
insert_predictions([%{prediction | revenue: :REVENUE}]) | ||
assert [%{headsign: "Last Stop on Shape", revenue: :REVENUE}] = by_id(@trip_id) | ||
assert [%{headsign: "Parent", revenue: :REVENUE}] = by_id(@trip_id) | ||
end | ||
|
||
test "creates a trip with revenue value set to false", | ||
%{prediction: prediction} do | ||
insert_predictions([%{prediction | revenue: :NON_REVENUE}]) | ||
assert [%{headsign: "Last Stop on Shape", revenue: :NON_REVENUE}] = by_id(@trip_id) | ||
assert [%{headsign: "Parent", revenue: :NON_REVENUE}] = by_id(@trip_id) | ||
end | ||
end | ||
|
||
|
@@ -267,19 +272,19 @@ defmodule State.Trip.AddedTest do | |
end) | ||
end | ||
|
||
test "if there's a matching route_pattern, use the representative trip" do | ||
test "if there's a matching route_pattern, use the last predicted stop" do | ||
insert_predictions([%{@prediction | stop_id: "child"}]) | ||
assert [%{headsign: "Headsign"}] = by_id(@trip_id) | ||
assert [%{headsign: "Parent"}] = by_id(@trip_id) | ||
end | ||
|
||
test "creates a trip with revenue value set to :REVENUE" do | ||
insert_predictions([%{@prediction | stop_id: "child", revenue: :REVENUE}]) | ||
assert [%{headsign: "Headsign", revenue: :REVENUE}] = by_id(@trip_id) | ||
assert [%{headsign: "Parent", revenue: :REVENUE}] = by_id(@trip_id) | ||
end | ||
|
||
test "creates a trip with revenue value set to :NON_REVENUE" do | ||
insert_predictions([%{@prediction | stop_id: "child", revenue: :NON_REVENUE}]) | ||
assert [%{headsign: "Headsign", revenue: :NON_REVENUE}] = by_id(@trip_id) | ||
assert [%{headsign: "Parent", revenue: :NON_REVENUE}] = by_id(@trip_id) | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this make the headsign different for each prediction? it seems like it's applying it to every prediction along the trip rather than applying the last stop's prediction's stopname as the headsign
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I should've called this out. Only the last prediction ever makes it to this function due to the reduce here. I can add the requested test to help demonstrate that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah that makes sense, misread it as a simple sorting rather than just keeping the last 👍