Skip to content

Commit

Permalink
remove unused fallbacks for destination utils (#852)
Browse files Browse the repository at this point in the history
  • Loading branch information
panentheos authored Dec 5, 2024
1 parent c8a1076 commit 8050099
Show file tree
Hide file tree
Showing 12 changed files with 203 additions and 248 deletions.
2 changes: 1 addition & 1 deletion lib/content/audio/first_train_scheduled.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ defmodule Content.Audio.FirstTrainScheduled do
destination: destination,
scheduled_time: scheduled_time
}) do
{:ok, destination} = PaEss.Utilities.destination_var(destination)
destination = PaEss.Utilities.destination_var(destination)

vars = [
@the_first,
Expand Down
38 changes: 17 additions & 21 deletions lib/content/audio/following_train.ex
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,23 @@ defmodule Content.Audio.FollowingTrain do
@minute "532"

def to_params(audio) do
case Utilities.destination_var(audio.destination) do
{:ok, dest_var} ->
if Utilities.directional_destination?(audio.destination) do
do_ad_hoc_message(audio)
else
green_line_branch = Content.Utilities.route_branch_letter(audio.route_id)

cond do
!is_nil(green_line_branch) ->
green_line_with_branch_params(audio, green_line_branch, dest_var)

audio.minutes == 1 ->
{:canned, {"159", [dest_var, verb_var(audio)], :audio}}

true ->
{:canned, {"160", [dest_var, verb_var(audio), minutes_var(audio)], :audio}}
end
end

{:error, :unknown} ->
do_ad_hoc_message(audio)
dest_var = Utilities.destination_var(audio.destination)

if Utilities.directional_destination?(audio.destination) do
do_ad_hoc_message(audio)
else
green_line_branch = Content.Utilities.route_branch_letter(audio.route_id)

cond do
!is_nil(green_line_branch) ->
green_line_with_branch_params(audio, green_line_branch, dest_var)

audio.minutes == 1 ->
{:canned, {"159", [dest_var, verb_var(audio)], :audio}}

true ->
{:canned, {"160", [dest_var, verb_var(audio), minutes_var(audio)], :audio}}
end
end
end

Expand Down
56 changes: 25 additions & 31 deletions lib/content/audio/next_train_countdown.ex
Original file line number Diff line number Diff line change
Expand Up @@ -49,45 +49,39 @@ defmodule Content.Audio.NextTrainCountdown do
@platform_when_closer "857"

def to_params(audio) do
case Utilities.destination_var(audio.destination) do
{:ok, dest_var} ->
green_line_branch = Content.Utilities.route_branch_letter(audio.route_id)
dest_var = Utilities.destination_var(audio.destination)
green_line_branch = Content.Utilities.route_branch_letter(audio.route_id)

cond do
Utilities.directional_destination?(audio.destination) ->
do_ad_hoc_message(audio)

!is_nil(audio.track_number) ->
terminal_track_params(audio, dest_var)
cond do
Utilities.directional_destination?(audio.destination) ->
do_ad_hoc_message(audio)

!is_nil(green_line_branch) ->
green_line_with_branch_params(audio, green_line_branch, dest_var)
!is_nil(audio.track_number) ->
terminal_track_params(audio, dest_var)

is_nil(audio.platform) and audio.minutes == 1 ->
{:canned, {"141", [dest_var, verb_var(audio)], :audio}}
!is_nil(green_line_branch) ->
green_line_with_branch_params(audio, green_line_branch, dest_var)

is_nil(audio.platform) ->
{:canned, {"90", [dest_var, verb_var(audio), minutes_var(audio)], :audio}}
is_nil(audio.platform) and audio.minutes == 1 ->
{:canned, {"141", [dest_var, verb_var(audio)], :audio}}

audio.minutes == 1 ->
{:canned, {"142", [dest_var, platform_var(audio), verb_var(audio)], :audio}}
is_nil(audio.platform) ->
{:canned, {"90", [dest_var, verb_var(audio), minutes_var(audio)], :audio}}

audio.destination == :alewife and audio.special_sign == :jfk_mezzanine and
audio.minutes > 5 ->
platform_tbd_params(
audio,
dest_var,
if(audio.minutes < 10, do: @platform_soon, else: @platform_when_closer)
)
audio.minutes == 1 ->
{:canned, {"142", [dest_var, platform_var(audio), verb_var(audio)], :audio}}

true ->
{:canned,
{"98", [dest_var, verb_var(audio), minutes_var(audio), platform_var(audio)],
:audio}}
end
audio.destination == :alewife and audio.special_sign == :jfk_mezzanine and
audio.minutes > 5 ->
platform_tbd_params(
audio,
dest_var,
if(audio.minutes < 10, do: @platform_soon, else: @platform_when_closer)
)

{:error, :unknown} ->
do_ad_hoc_message(audio)
true ->
{:canned,
{"98", [dest_var, verb_var(audio), minutes_var(audio), platform_var(audio)], :audio}}
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/content/audio/no_service.ex
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ defmodule Content.Audio.NoService do
end

if destination do
{:ok, destination_text} = PaEss.Utilities.destination_to_ad_hoc_string(destination)
destination_text = PaEss.Utilities.destination_to_ad_hoc_string(destination)
"No #{destination_text} service.#{suffix}"
else
line = if(route, do: "#{route} Line", else: "train")
Expand Down
30 changes: 8 additions & 22 deletions lib/content/audio/service_ended.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,14 @@ defmodule Content.Audio.ServiceEnded do
Utilities.take_message([line_var, @service_ended], :audio)
end

def to_params(
%Content.Audio.ServiceEnded{location: :platform, destination: destination} = audio
) do
case Utilities.destination_var(destination) do
{:ok, destination_var} ->
Utilities.take_message([@platform_closed, destination_var, @service_ended], :audio)

{:error, :unknown} ->
{:ad_hoc, {tts_text(audio), :audio}}
end
def to_params(%Content.Audio.ServiceEnded{location: :platform, destination: destination}) do
destination_var = Utilities.destination_var(destination)
Utilities.take_message([@platform_closed, destination_var, @service_ended], :audio)
end

def to_params(
%Content.Audio.ServiceEnded{location: :direction, destination: destination} = audio
) do
case Utilities.destination_var(destination) do
{:ok, destination_var} ->
Utilities.take_message([destination_var, @service_ended], :audio)

{:error, :unknown} ->
{:ad_hoc, {tts_text(audio), :audio}}
end
def to_params(%Content.Audio.ServiceEnded{location: :direction, destination: destination}) do
destination_var = Utilities.destination_var(destination)
Utilities.take_message([destination_var, @service_ended], :audio)
end

def to_tts(%Content.Audio.ServiceEnded{} = audio) do
Expand All @@ -70,12 +56,12 @@ defmodule Content.Audio.ServiceEnded do
end

defp tts_text(%Content.Audio.ServiceEnded{location: :platform, destination: destination}) do
{:ok, destination_string} = Utilities.destination_to_ad_hoc_string(destination)
destination_string = Utilities.destination_to_ad_hoc_string(destination)
"This platform is closed. #{destination_string} service has ended for the night."
end

defp tts_text(%Content.Audio.ServiceEnded{location: :direction, destination: destination}) do
{:ok, destination_string} = Utilities.destination_to_ad_hoc_string(destination)
destination_string = Utilities.destination_to_ad_hoc_string(destination)
"#{destination_string} service has ended for the night."
end
end
Expand Down
34 changes: 14 additions & 20 deletions lib/content/audio/stopped_train.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,20 @@ defmodule Content.Audio.StoppedTrain do
@stopped "641"

def to_params(audio) do
case PaEss.Utilities.destination_var(audio.destination) do
{:ok, dest_var} ->
if Utilities.directional_destination?(audio.destination) do
do_ad_hoc_message(audio)
else
vars = [
@the_next,
@train_to,
dest_var,
@is,
@stopped,
number_var(audio.stops_away),
stops_away_var(audio.stops_away)
]

PaEss.Utilities.take_message(vars, :audio)
end

{:error, :unknown} ->
do_ad_hoc_message(audio)
if Utilities.directional_destination?(audio.destination) do
do_ad_hoc_message(audio)
else
vars = [
@the_next,
@train_to,
PaEss.Utilities.destination_var(audio.destination),
@is,
@stopped,
number_var(audio.stops_away),
stops_away_var(audio.stops_away)
]

PaEss.Utilities.take_message(vars, :audio)
end
end

Expand Down
14 changes: 4 additions & 10 deletions lib/content/audio/train_is_boarding.ex
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,10 @@ defmodule Content.Audio.TrainIsBoarding do
@on_track_2 "542"

def to_params(audio) do
case PaEss.Utilities.destination_var(audio.destination) do
{:ok, destination_var} ->
if PaEss.Utilities.directional_destination?(audio.destination) do
do_ad_hoc_message(audio)
else
do_to_params(audio, destination_var)
end

{:error, :unknown} ->
do_ad_hoc_message(audio)
if PaEss.Utilities.directional_destination?(audio.destination) do
do_ad_hoc_message(audio)
else
do_to_params(audio, PaEss.Utilities.destination_var(audio.destination))
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/content/audio/vehicles_to_destination.ex
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ defmodule Content.Audio.VehiclesToDestination do
"#{route} line trains"

{destination, _} ->
{:ok, destination_text} = PaEss.Utilities.destination_to_ad_hoc_string(destination)
destination_text = PaEss.Utilities.destination_to_ad_hoc_string(destination)
"#{destination_text} trains"
end

Expand Down
Loading

0 comments on commit 8050099

Please sign in to comment.