Skip to content

Commit

Permalink
Made now it's own required parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaddox5 committed Sep 11, 2024
1 parent 0dae7ca commit e72b5af
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/screens/v2/candidate_generator/bus_eink.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ defmodule Screens.V2.CandidateGenerator.BusEink do
) do
[
fn -> header_instances(config, now, fetch_stop_name_fn) end,
fn -> departures_instances_fn.(config, now: now) end,
fn -> departures_instances_fn.(config, now) end,
fn -> alert_instances_fn.(config) end,
fn -> footer_instances(config) end,
fn -> evergreen_content_instances_fn.(config) end,
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/v2/candidate_generator/bus_shelter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ defmodule Screens.V2.CandidateGenerator.BusShelter do
) do
[
fn -> header_instances(config, now, fetch_stop_name_fn) end,
fn -> departures_instances_fn.(config, now: now) end,
fn -> departures_instances_fn.(config, now) end,
fn -> alert_instances_fn.(config) end,
fn -> footer_instances(config) end,
fn -> subway_status_instances_fn.(config, now) end,
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/v2/candidate_generator/busway.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ defmodule Screens.V2.CandidateGenerator.Busway do

[
fn -> header_instances(config, now) end,
fn -> deps.departures_instances.(config, now: now) end,
fn -> deps.departures_instances.(config, now) end,
fn -> placeholder_instances() end
]
|> Task.async_stream(& &1.(), timeout: 15_000)
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/v2/candidate_generator/gl_eink.ex
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ defmodule Screens.V2.CandidateGenerator.GlEink do
[
fn -> header_instances(config, now, fetch_destination_fn) end,
fn ->
departures_instances_fn.(config, post_process_fn: &departures_post_processing/2, now: now)
departures_instances_fn.(config, now, post_process_fn: &departures_post_processing/2)
end,
fn -> alert_instances_fn.(config) end,
fn -> footer_instances(config) end,
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/v2/candidate_generator/solari_large.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ defmodule Screens.V2.CandidateGenerator.SolariLarge do
) do
[
fn -> header_instances(config, now) end,
fn -> departures_instances_fn.(config, now: now) end,
fn -> departures_instances_fn.(config, now) end,
fn -> placeholder_instances() end
]
|> Task.async_stream(& &1.(), timeout: 15_000)
Expand Down
7 changes: 2 additions & 5 deletions lib/screens/v2/candidate_generator/widgets/departures.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ defmodule Screens.V2.CandidateGenerator.Widgets.Departures do
| OvernightDepartures.t()

@spec departures_instances(Screen.t(), options()) :: [widget()]
def departures_instances(
%Screen{app_params: %app{}} = config,
options
)
def departures_instances(%Screen{app_params: %app{}} = config, now, options \\ [])
when app in [BusEink, BusShelter, Busway, GlEink, SolariLarge] do
disabled_modes =
Keyword.get(options, :disabled_modes_fn, &Screens.Config.Cache.disabled_modes/0).()
Expand All @@ -53,7 +50,7 @@ defmodule Screens.V2.CandidateGenerator.Widgets.Departures do
Keyword.get(options, :departure_fetch_fn, &Departure.fetch/2),
Keyword.get(options, :post_process_fn, fn results, _config -> results end),
Keyword.get(options, :route_fetch_fn, &Route.fetch/1),
options[:now]
now
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ defmodule Screens.V2.CandidateGenerator.Widgets.DeparturesTest do
}
end

describe "departures_instances/1" do
describe "departures_instances/3" do
defp build_config(section_route_ids) do
%Screen{
app_params: %BusShelter{
Expand Down Expand Up @@ -62,6 +62,7 @@ defmodule Screens.V2.CandidateGenerator.Widgets.DeparturesTest do
defp departures_instances(config, options) do
Departures.departures_instances(
config,
nil,
Keyword.merge(
[
departure_fetch_fn: fn _, _ -> :error end,
Expand Down

0 comments on commit e72b5af

Please sign in to comment.