Skip to content

Commit

Permalink
refactor messages
Browse files Browse the repository at this point in the history
  • Loading branch information
panentheos committed Oct 8, 2024
1 parent ec5a827 commit a8c4421
Show file tree
Hide file tree
Showing 7 changed files with 313 additions and 724 deletions.
27 changes: 7 additions & 20 deletions lib/signs/realtime.ex
Original file line number Diff line number Diff line change
Expand Up @@ -145,21 +145,16 @@ defmodule Signs.Realtime do
current_time = sign.current_time_fn.()

alert_status =
sign.source_config
|> map_source_config(&get_alert_status_for_source_config(&1, sign.alerts_engine))
|> then(fn
{alert_status, alert_status} -> alert_status
alert_status -> alert_status
map_source_config(sign.source_config, fn config ->
stop_ids = SourceConfig.sign_stop_ids(config)
routes = SourceConfig.sign_routes(config)
sign.alerts_engine.max_stop_status(stop_ids, routes)
end)

first_scheduled_departures =
sign.source_config
|> map_source_config(
&{
sign.headway_engine.get_first_scheduled_departure(SourceConfig.sign_stop_ids(&1)),
&1.headway_destination
}
)
map_source_config(sign.source_config, fn config ->
sign.headway_engine.get_first_scheduled_departure(SourceConfig.sign_stop_ids(config))
end)

prev_predictions_lookup =
for prediction <- sign.prev_predictions, into: %{} do
Expand Down Expand Up @@ -280,14 +275,6 @@ defmodule Signs.Realtime do
%{sign | tick_read: sign.tick_read - 1}
end

defp get_alert_status_for_source_config(config, alerts_engine) do
stop_ids = SourceConfig.sign_stop_ids(config)
routes = SourceConfig.sign_routes(config)
alert_status = alerts_engine.max_stop_status(stop_ids, routes)

alert_status
end

defp map_source_config({top, bottom}, fun), do: {fun.(top), fun.(bottom)}
defp map_source_config(config, fun), do: fun.(config)
end
344 changes: 0 additions & 344 deletions lib/signs/utilities/early_am_suppression.ex

This file was deleted.

Loading

0 comments on commit a8c4421

Please sign in to comment.