Skip to content

Commit

Permalink
fix(RealtimeSchedule): partial revert of #1915 (#1920)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecristen authored Mar 15, 2024
1 parent 6a94082 commit 37f6809
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/dotcom/realtime_schedule.ex
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,13 @@ defmodule Dotcom.RealtimeSchedule do
Task.async(fn ->
next_two_predictions =
[
route: route_pattern.route_id,
direction_id: route_pattern.direction_id
stop: stop_id,
route_pattern: route_pattern.id,
sort: "time",
"page[limit]": @predicted_schedules_per_stop
]
|> predictions_fn.()
|> Enum.filter(& &1.time)
|> Enum.filter(&(&1.stop.id == stop_id && &1.trip.route_pattern_id == route_pattern.id))
|> Enum.take(@predicted_schedules_per_stop)

{key, next_two_predictions}
end)
Expand Down
3 changes: 3 additions & 0 deletions lib/predictions/repo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ defmodule Predictions.Repo do
defp add_all_optional_params(opts) do
@default_params
|> add_optional_param(opts, :route)
|> add_optional_param(opts, :stop)
|> add_optional_param(opts, :direction_id)
|> add_optional_param(opts, :trip)
|> add_optional_param(opts, :route_pattern)
|> add_optional_param(opts, :"page[limit]")
|> add_optional_param(opts, :sort)
end

Expand Down
43 changes: 43 additions & 0 deletions test/dotcom/realtime_schedule_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,49 @@ defmodule Dotcom.RealtimeScheduleTest do
%{
stop: %{accessibility: [], address: nil, id: "place-ogmnl", name: nil, parking_lots: []},
predicted_schedules_by_route_pattern: %{
"Forest Hills" => %{
direction_id: 0,
predicted_schedules: [
%{
prediction: %{
__struct__: Predictions.Prediction,
departing?: false,
direction_id: 1,
id: "prediction-40709316-70036-190",
schedule_relationship: nil,
status: nil,
stop_sequence: 190,
arrival_time: @now,
departure_time: @now_departure,
time: ["arriving"],
track: nil,
headsign: "Oak Grove",
vehicle_id: "vehicle_id",
platform_stop_id: "70036"
},
schedule: nil
},
%{
prediction: %{
__struct__: Predictions.Prediction,
departing?: false,
direction_id: 1,
id: "prediction-40709317-70036-190",
schedule_relationship: nil,
status: nil,
stop_sequence: 190,
arrival_time: @now,
departure_time: @now_departure,
time: ["arriving"],
track: nil,
headsign: "Oak Grove",
vehicle_id: nil,
platform_stop_id: "70036"
},
schedule: nil
}
]
},
"Oak Grove" => %{
direction_id: 1,
predicted_schedules: [
Expand Down

0 comments on commit 37f6809

Please sign in to comment.