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

unify prediction audios #870

Merged
merged 2 commits into from
Jan 16, 2025
Merged

unify prediction audios #870

merged 2 commits into from
Jan 16, 2025

Conversation

panentheos
Copy link
Collaborator

Summary of changes

This combines the NextTrainCountdown, FollowingTrain, and StoppedTrain audio modules into one unified module. The goal is to reduce some overlapping logic between these code paths, and pave the way for future refactoring.

This includes a slight wording change on JFK platforms readouts, which was ok'd by product and is illustrated with a new test case. The other test deltas are minor capitalization and punctuation changes to TTS strings resulting from standardizing the code, which shouldn't substantially affect the output.

@panentheos panentheos requested a review from a team as a code owner January 13, 2025 22:06
Comment on lines 6 to 24
[
%__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
[
%__MODULE__{
prediction: message.prediction,
special_sign: message.special_sign,
terminal?: message.terminal?,
next_or_following: next_or_following
}
]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these two clauses are doing the same thing, is it worth separating the struct instantiation into a helper?

lib/content/audio/predictions.ex Show resolved Hide resolved

cond do
!platform -> {nil, false, nil}
jfk_mezzanine? and minutes > 9 -> {nil, false, :later}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With documentation/posterity (although I think the typespec mostly covers that) and avoiding "magic numbers" in code in mind, it might be worthwhile if we swap out 9 and 5 for some module attributes. @announce_platform_later_threshold and @announce_platform_soon_threshold or something along those lines?

Copy link
Collaborator

@PaulJKim PaulJKim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@panentheos panentheos merged commit 6f89a77 into main Jan 16, 2025
2 checks passed
@panentheos panentheos deleted the bhw/prediction-audio branch January 16, 2025 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants