Skip to content

Commit

Permalink
fix(Routes.Repo): log errors in by_stop_route_route_pattern (#1934)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecristen authored Mar 20, 2024
1 parent f0c41a9 commit 9a1fbfd
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions lib/routes/repo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,28 @@ defmodule Routes.Repo do
end

@impl Routes.RepoApi
@decorate cacheable(cache: @cache, on_error: :nothing, opts: [ttl: @ttl])
def by_stop_with_route_pattern(stop_id) do
[stop: stop_id, include: "route_patterns"]
|> V3Api.Routes.all()
|> Map.get(:data, [])
|> Enum.map(&parse_route_with_route_pattern/1)
case do_by_stop_with_route_pattern(stop: stop_id, include: "route_patterns") do
%{data: data} ->
Enum.map(data, &parse_route_with_route_pattern/1)

error ->
Logger.error(
"#{__MODULE__} by_stop_with_route_pattern stop_id=#{stop_id} error=#{inspect(error)}"
)

[]
end
end

@decorate cacheable(
cache: @cache,
match: fn %{data: data} -> is_list(data) && data != [] end,
on_error: :nothing,
opts: [ttl: @ttl]
)
def do_by_stop_with_route_pattern(opts) do
V3Api.Routes.all(opts)
end

@doc """
Expand Down

0 comments on commit 9a1fbfd

Please sign in to comment.