diff --git a/apps/schedules/lib/repo_condensed.ex b/apps/schedules/lib/repo_condensed.ex index 715b0a41a6..0a27c70d67 100644 --- a/apps/schedules/lib/repo_condensed.ex +++ b/apps/schedules/lib/repo_condensed.ex @@ -3,6 +3,9 @@ defmodule Schedules.RepoCondensed do An alternate way to fetch schedules that is more light weight and easier to cache. + This uses a longer than usual timeout for initial caching as sometime (especially in dev) + it may take a long time to warm the cache. + """ import Kernel, except: [to_string: 1] use RepoCache, ttl: :timer.hours(1) @@ -28,7 +31,7 @@ defmodule Schedules.RepoCondensed do |> add_optional_param(opts, :direction_id) |> add_optional_param(opts, :stop_sequences, :stop_sequence) |> add_optional_param(opts, :stop_ids, :stop) - |> cache(&all_from_params/1) + |> cache(&all_from_params/1, timeout: 10_000) |> filter_by_min_time(Keyword.get(opts, :min_time)) end diff --git a/apps/site/lib/site/realtime_schedule.ex b/apps/site/lib/site/realtime_schedule.ex index a39bb4115e..6a1c1da34b 100644 --- a/apps/site/lib/site/realtime_schedule.ex +++ b/apps/site/lib/site/realtime_schedule.ex @@ -122,7 +122,7 @@ defmodule Site.RealtimeSchedule do do_get_predictions(stop_id, route_patterns, predictions_fn) end) end) - |> Enum.flat_map(&Task.await/1) + |> Enum.flat_map(&Task.await(&1, @long_timeout)) |> Enum.reduce(%{}, fn {route_key, predictions}, accumulator -> data = if Map.has_key?(accumulator, route_key) do @@ -172,7 +172,7 @@ defmodule Site.RealtimeSchedule do {key, next_two_predictions} end) end) - |> Enum.map(&Task.await/1) + |> Enum.map(&Task.await(&1, @long_timeout)) end @spec get_schedules([route_with_patterns_t], DateTime.t(), fun()) :: map