Skip to content

Commit

Permalink
Condense logging code
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulJKim committed Aug 31, 2023
1 parent 101c9d5 commit 3b5e949
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions lib/signs/utilities/audio.ex
Original file line number Diff line number Diff line change
Expand Up @@ -209,31 +209,26 @@ defmodule Signs.Utilities.Audio do

defp log_crowding(new_audios, sign_id) do
Enum.each(new_audios, fn
%Audio.Approaching{
%{
trip_id: trip_id,
crowding_description: crowding_description,
route_id: route_id
route_id: "Orange",
__struct__: audio_type
}
when route_id == "Orange" ->
Logger.info(
"crowding_log: announcement_type=approaching trip_id=#{trip_id} sign_id=#{sign_id} crowding_included=#{not is_nil(crowding_description)} crowding_desciption=#{inspect(crowding_description)}"
)
when audio_type in [Audio.Approaching, Audio.TrainIsArriving] ->
announcement_type =
case audio_type do
Audio.Approaching -> "approaching"
Audio.TrainIsArriving -> "arrival"
end

%Audio.TrainIsArriving{
trip_id: trip_id,
crowding_description: crowding_description,
route_id: route_id
}
when route_id == "Orange" ->
Logger.info(
"crowding_log: announcement_type=arrival trip_id=#{trip_id} sign_id=#{sign_id} crowding_included=#{not is_nil(crowding_description)} crowding_desciption=#{inspect(crowding_description)}"
"crowding_log: announcement_type=#{announcement_type} trip_id=#{trip_id} sign_id=#{sign_id} crowding_description=#{inspect(crowding_description)}"
)

_ ->
nil
end)

new_audios
end

@spec sort_audio([Content.Audio.t()]) :: [Content.Audio.t()]
Expand Down

0 comments on commit 3b5e949

Please sign in to comment.