Skip to content

Commit

Permalink
don't offset terminal predictions
Browse files Browse the repository at this point in the history
  • Loading branch information
panentheos committed Nov 19, 2024
1 parent f6fe3ff commit 4a6ec31
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
2 changes: 1 addition & 1 deletion lib/content/message/predictions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ defmodule Content.Message.Predictions do
def new(%Predictions.Prediction{} = prediction, terminal?, special_sign) do
sec =
if terminal? do
prediction.seconds_until_departure - 60
prediction.seconds_until_departure
else
prediction.seconds_until_arrival || prediction.seconds_until_departure
end
Expand Down
22 changes: 3 additions & 19 deletions test/content/messages/predictions_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ defmodule Content.Message.PredictionsTest do
describe "terminal new/3" do
test "puts boarding on the sign when train is supposed to be boarding according to rtr" do
prediction = %Predictions.Prediction{
seconds_until_departure: 75,
seconds_until_departure: 15,
direction_id: 1,
route_id: "Mattapan",
destination_stop_id: "70261",
Expand All @@ -244,7 +244,7 @@ defmodule Content.Message.PredictionsTest do

test "does not put boarding on the sign too early when train is stopped at terminal" do
prediction = %Predictions.Prediction{
seconds_until_departure: 95,
seconds_until_departure: 35,
direction_id: 1,
route_id: "Mattapan",
destination_stop_id: "70261",
Expand All @@ -258,22 +258,6 @@ defmodule Content.Message.PredictionsTest do
assert Content.Message.to_string(msg) == "Ashmont 1 min"
end

test "offsets the prediction by 60 seconds" do
prediction = %Predictions.Prediction{
seconds_until_departure: 209,
direction_id: 1,
route_id: "Mattapan",
destination_stop_id: "70261",
stopped?: false,
stops_away: 0,
boarding_status: "Stopped at station"
}

msg = Content.Message.Predictions.new(prediction, true, nil)

assert Content.Message.to_string(msg) == "Ashmont 2 min"
end

test "puts 1 min on the sign when train is not boarding, but is predicted to depart in less than a minute when offset" do
prediction = %Predictions.Prediction{
seconds_until_departure: 70,
Expand All @@ -292,7 +276,7 @@ defmodule Content.Message.PredictionsTest do
test "pages track information when available" do
prediction = %Predictions.Prediction{
stop_id: "Forest Hills-02",
seconds_until_departure: 180,
seconds_until_departure: 120,
direction_id: 1,
route_id: "Orange",
stopped?: false,
Expand Down
2 changes: 1 addition & 1 deletion test/signs/realtime_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ defmodule Signs.RealtimeTest do
]
end)

expect_messages({"Boston Col 3 min", "Clvlnd Cir 4 min"})
expect_messages({"Boston Col 4 min", "Clvlnd Cir 5 min"})
Signs.Realtime.handle_info(:run_loop, @terminal_sign)
end

Expand Down

0 comments on commit 4a6ec31

Please sign in to comment.