Skip to content

Commit

Permalink
Log locations
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulJKim committed Aug 9, 2024
1 parent 44bd222 commit 526b65c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
8 changes: 7 additions & 1 deletion lib/content/message/predictions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,13 @@ defmodule Content.Message.Predictions do
" seconds_until_departure=",
inspect(prediction.seconds_until_departure),
" boarding_status=",
inspect(prediction.boarding_status)
inspect(prediction.boarding_status),
" vehicle_status=",
inspect(prediction.vehicle_status),
" vehicle_location_stop_id=",
inspect(prediction.vehicle_location_stop_id),
" vehicle_location_trip_id=",
inspect(prediction.vehicle_location_trip_id)
])
end

Expand Down
10 changes: 8 additions & 2 deletions lib/predictions/prediction.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ defmodule Predictions.Prediction do
stops_away: 0,
boarding_status: nil,
revenue_trip?: true,
vehicle_id: nil
vehicle_id: nil,
vehicle_status: nil,
vehicle_location_stop_id: nil,
vehicle_location_trip_id: nil

@type trip_id :: String.t()

Expand All @@ -34,6 +37,9 @@ defmodule Predictions.Prediction do
stops_away: integer(),
boarding_status: String.t() | nil,
revenue_trip?: boolean(),
vehicle_id: String.t() | nil
vehicle_id: String.t() | nil,
vehicle_status: nil,
vehicle_location_stop_id: nil,
vehicle_location_trip_id: nil
}
end
14 changes: 13 additions & 1 deletion lib/predictions/predictions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ defmodule Predictions.Predictions do
do: stop_time_update["passthrough_time"] - current_time_seconds,
else: nil

vehicle_location = Engine.Locations.for_vehicle(vehicle_id)
vehicle_status = if not is_nil(vehicle_location), do: vehicle_location.status, else: "none"

vehicle_location_stop_id =
if not is_nil(vehicle_location), do: vehicle_location.stop_id, else: "none"

vehicle_location_trip_id =
if not is_nil(vehicle_location), do: vehicle_location.trip_id, else: "none"

%Prediction{
stop_id: stop_time_update["stop_id"],
direction_id: direction_id,
Expand All @@ -101,7 +110,10 @@ defmodule Predictions.Predictions do
stops_away: stop_time_update["stops_away"],
boarding_status: stop_time_update["boarding_status"],
revenue_trip?: revenue_trip?,
vehicle_id: vehicle_id
vehicle_id: vehicle_id,
vehicle_status: vehicle_status,
vehicle_location_stop_id: vehicle_location_stop_id,
vehicle_location_trip_id: vehicle_location_trip_id
}
end

Expand Down

0 comments on commit 526b65c

Please sign in to comment.