Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
panentheos committed Jan 14, 2025
1 parent ea2473e commit ec4252d
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions lib/content/audio/predictions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ defmodule Content.Audio.Predictions do
@enforce_keys [:prediction, :special_sign, :terminal?, :next_or_following]
defstruct @enforce_keys

def from_message(%Content.Message.Predictions{} = message, next_or_following) do
[
%__MODULE__{
prediction: message.prediction,
special_sign: message.special_sign,
terminal?: message.terminal?,
next_or_following: next_or_following
}
]
end

def from_message(%Content.Message.StoppedTrain{} = message, next_or_following) do
@type t :: %__MODULE__{
prediction: Predictions.Prediction.t(),
special_sign: :jfk_mezzanine | :bowdoin_eastbound | nil,
terminal?: boolean(),
next_or_following: :next | :following
}

@spec from_message(
Content.Message.Predictions.t() | Content.Message.StoppedTrain.t(),
:next | :following
) :: [t()]
def from_message(message, next_or_following) do
[
%__MODULE__{
prediction: message.prediction,
Expand All @@ -25,6 +25,9 @@ defmodule Content.Audio.Predictions do
end

defimpl Content.Audio do
@announce_platform_later_mins 9
@announce_platform_soon_mins 5

def to_params(%Content.Audio.Predictions{prediction: prediction} = audio) do
destination = Content.Utilities.destination_for_prediction(prediction)

Expand Down Expand Up @@ -124,8 +127,8 @@ defmodule Content.Audio.Predictions do

cond do
!platform -> {nil, false, nil}
jfk_mezzanine? and minutes > 9 -> {nil, false, :later}
jfk_mezzanine? and minutes > 5 -> {nil, false, :soon}
jfk_mezzanine? and minutes > @announce_platform_later_mins -> {nil, false, :later}
jfk_mezzanine? and minutes > @announce_platform_soon_mins -> {nil, false, :soon}
minutes == 1 or !jfk_mezzanine? -> {platform, true, nil}
true -> {platform, false, nil}
end
Expand Down

0 comments on commit ec4252d

Please sign in to comment.