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

Add stop headsign to repo condensed #2396

Merged
merged 2 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 4 additions & 6 deletions lib/schedules/repo_condensed.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule Schedules.RepoCondensed do
@default_params [
include: "trip,trip.occupancies",
"fields[schedule]":
"departure_time,arrival_time,drop_off_type,pickup_type,stop_sequence,timepoint",
"departure_time,arrival_time,drop_off_type,pickup_type,stop_sequence,stop_headsign,timepoint",
"fields[trip]": "name,headsign,direction_id,bikes_allowed"
]

Expand Down Expand Up @@ -56,13 +56,11 @@ defmodule Schedules.RepoCondensed do
end
end

defp has_trip?({_, trip_id, _, _, _, _, _, _, _, _, _}) when is_nil(trip_id) do
defp has_trip?({_, trip_id, _, _, _, _, _, _, _, _, _, _}) when is_nil(trip_id) do
false
end

defp has_trip?({_, _, _, _, _, _, _, _, _, _, _}) do
true
end
defp has_trip?(_), do: true

defp valid?(%JsonApi.Item{relationships: %{"trip" => [%JsonApi.Item{id: id} | _]}})
when not is_nil(id) do
Expand Down Expand Up @@ -119,7 +117,7 @@ defmodule Schedules.RepoCondensed do

defp build_structs(schedules) do
schedules
|> Enum.map(fn {_, trip_id, stop_id, _, _, time, _, _, _, stop_sequence, _} ->
|> Enum.map(fn {_, trip_id, stop_id, _, _, time, _, _, _, stop_sequence, _, _} ->
Task.async(fn ->
trip = Repo.trip(trip_id)
stop = @stops_repo.get!(stop_id)
Expand Down
2 changes: 2 additions & 0 deletions lib/schedules/schedule.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ defmodule Schedules.ScheduleCondensed do
route_pattern_id: nil,
train_number: nil,
stop_sequence: 0,
stop_headsign: nil,
headsign: nil

@type t :: %Schedules.ScheduleCondensed{
Expand All @@ -63,6 +64,7 @@ defmodule Schedules.ScheduleCondensed do
route_pattern_id: String.t() | nil,
train_number: String.t() | nil,
stop_sequence: non_neg_integer,
stop_headsign: String.t() | nil,
headsign: String.t()
}
end
Expand Down