From 8e920f5eac942395b555368ebf651325d8286649 Mon Sep 17 00:00:00 2001 From: Cristen Jones Date: Tue, 7 May 2024 22:07:06 -0400 Subject: [PATCH] fix: try captured function this way --- lib/dotcom/realtime_schedule.ex | 2 +- lib/dotcom/trip_plan/itinerary_row.ex | 2 +- lib/dotcom/trip_plan/map.ex | 2 +- lib/dotcom/trip_plan/related_link.ex | 5 ++++- lib/dotcom_web/controllers/schedule/line.ex | 6 +++++- lib/stops/nearby.ex | 5 +++-- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/dotcom/realtime_schedule.ex b/lib/dotcom/realtime_schedule.ex index 440b18c58e..1baac10e48 100644 --- a/lib/dotcom/realtime_schedule.ex +++ b/lib/dotcom/realtime_schedule.ex @@ -27,7 +27,7 @@ defmodule Dotcom.RealtimeSchedule do @predicted_schedules_per_stop 2 @default_opts [ - stops_fn: {@stops_repo, :get, 1}, + stops_fn: Function.capture(@stops_repo, :get, 1), routes_fn: &RoutesRepo.by_stop_with_route_pattern/1, predictions_fn: &PredictionsRepo.all_no_cache/1, schedules_fn: &SchedulesRepo.by_route_ids/2, diff --git a/lib/dotcom/trip_plan/itinerary_row.ex b/lib/dotcom/trip_plan/itinerary_row.ex index d3c3e9022b..3e18edde86 100644 --- a/lib/dotcom/trip_plan/itinerary_row.ex +++ b/lib/dotcom/trip_plan/itinerary_row.ex @@ -19,7 +19,7 @@ defmodule Dotcom.TripPlan.ItineraryRow do @type trip_mapper :: (Schedules.Trip.id_t() -> Schedules.Trip.t() | nil) @type alerts_repo :: (DateTime.t() -> [Alerts.Alert.t()] | nil) - defstruct stop_mapper: {@stops_repo, :get_parent, 1}, + defstruct stop_mapper: Function.capture(@stops_repo, :get_parent, 1), route_mapper: &Routes.Repo.get/1, trip_mapper: &Schedules.Repo.trip/1, alerts_repo: &Alerts.Repo.all/1 diff --git a/lib/dotcom/trip_plan/map.ex b/lib/dotcom/trip_plan/map.ex index bb3d65783a..be02692391 100644 --- a/lib/dotcom/trip_plan/map.ex +++ b/lib/dotcom/trip_plan/map.ex @@ -12,7 +12,7 @@ defmodule Dotcom.TripPlan.Map do @stops_repo Application.compile_env!(:dotcom, :repo_modules)[:stops] @default_opts [ route_mapper: &Routes.Repo.get/1, - stop_mapper: {@stops_repo, :get_parent, 1} + stop_mapper: Function.capture(@stops_repo, :get_parent, 1) ] @moduledoc """ diff --git a/lib/dotcom/trip_plan/related_link.ex b/lib/dotcom/trip_plan/related_link.ex index a6c19036ba..b3910d4ce8 100644 --- a/lib/dotcom/trip_plan/related_link.ex +++ b/lib/dotcom/trip_plan/related_link.ex @@ -14,7 +14,10 @@ defmodule Dotcom.TripPlan.RelatedLink do icon_name: nil @stops_repo Application.compile_env!(:dotcom, :repo_modules)[:stops] - @default_opts [route_by_id: &Routes.Repo.get/1, stop_by_id: {@stops_repo, :get_parent, 1}] + @default_opts [ + route_by_id: &Routes.Repo.get/1, + stop_by_id: Function.capture(@stops_repo, :get_parent, 1) + ] import Phoenix.HTML.Link, only: [link: 2] # Need a view in order to use the components. Ideally we'd have a separate diff --git a/lib/dotcom_web/controllers/schedule/line.ex b/lib/dotcom_web/controllers/schedule/line.ex index d53abf3bd2..209f09f203 100644 --- a/lib/dotcom_web/controllers/schedule/line.ex +++ b/lib/dotcom_web/controllers/schedule/line.ex @@ -22,7 +22,11 @@ defmodule DotcomWeb.ScheduleController.Line do @type t :: %__MODULE__{ stops_by_route_fn: - {Application.compile_env!(:dotcom, :repo_modules)[:stops], :by_route, 3} + Function.capture( + Application.compile_env!(:dotcom, :repo_modules)[:stops], + :by_route, + 3 + ) } end diff --git a/lib/stops/nearby.ex b/lib/stops/nearby.ex index 31991bf715..07cae62152 100644 --- a/lib/stops/nearby.ex +++ b/lib/stops/nearby.ex @@ -13,11 +13,12 @@ defmodule Stops.Nearby do @type route_with_direction :: %{direction_id: 0 | 1 | nil, route: Route.t()} defmodule Options do + @stops_repo Application.compile_env!(:dotcom, :repo_modules)[:stops] + @moduledoc "Defines shared options and defaults for this module's functions." defstruct api_fn: &Stops.Nearby.api_around/2, keys_fn: &Stops.Nearby.keys/1, - fetch_fn: - {Application.compile_env!(:dotcom, :repo_modules)[:stops], :get_parent, 1}, + fetch_fn: Function.capture(@stops_repo, :get_parent, 1), routes_fn: &Routes.Repo.by_stop_and_direction/2, limit: nil end