Skip to content

Commit

Permalink
allow longer time for realtime cache to warm (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-mahoney authored Aug 30, 2019
1 parent a4f5267 commit bffb915
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion apps/schedules/lib/repo_condensed.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions apps/site/lib/site/realtime_schedule.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bffb915

Please sign in to comment.