Skip to content

Commit

Permalink
hotfix: restore bus routes on stop pages
Browse files Browse the repository at this point in the history
fix the logical error: checking against the route pattern's single associated service ID is too strict, because routes will make trips associated with many additional services. ameliorate by checking against all services for the route pattern's route.
  • Loading branch information
thecristen committed Oct 29, 2023
1 parent 9f1485c commit a0bf515
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions apps/site/lib/site_web/controllers/stop_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,13 @@ defmodule SiteWeb.StopController do
# Canonical route patterns don't serve any date! Just ignore in this case
defp not_serving_today?(%RoutePattern{typicality: :canonical}), do: false

defp not_serving_today?(%RoutePattern{service_id: service_id})
when is_binary(service_id) do
case Services.Repo.by_id(service_id) do
%Service{} = service ->
not Service.serves_date?(service, Timex.today())
defp not_serving_today?(%RoutePattern{route_id: route_id})
when is_binary(route_id) do
case Services.Repo.by_route_id(route_id) do
[%Service{} | _] = services ->
services
|> Enum.filter(&Service.serves_date?(&1, Timex.today()))
|> Enum.empty?()

_ ->
false
Expand Down

0 comments on commit a0bf515

Please sign in to comment.