Skip to content

refactor(SystemStatus.CommuterRail): use service check - #3377

Open
thecristen wants to merge 3 commits into
mainfrom
cbj/system-status-service-today
Open

refactor(SystemStatus.CommuterRail): use service check#3377
thecristen wants to merge 3 commits into
mainfrom
cbj/system-status-service-today

Conversation

@thecristen

@thecristen thecristen commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Scope

This PR covers a few things I noticed while analyzing the homepage.

Implementation

Checking if a commuter rail route has service today

It's not directly related to the homepage, but as the system became overwhelmed and various things fell apart, one call that'd sometimes fail is this which feeds into the Commuter Rail Status widget:

  # Returns a boolean indicating whether or not the route has a schedule
  # for today. This is used to determine if the route is running service today.
  @spec service_today?(String.t()) :: boolean()
  defp service_today?(id) do
    [id]
    |> @schedules_condensed_repo.by_route_ids()
    |> Enum.any?(fn %{time: time} -> Dotcom.Utils.ServiceDateTime.service_today?(time) end)
  end

This PR replaces this with the existing Dotcom.ServicePatterns.has_service?/1 function, which defaults to checking the current service date and uses a much simpler check (against V3 API /service result rather than checking times in each result from /schedules).

Getting alerts for each status widget

Both subway_alert_groups() and commuter_rail_alert_groups() currently fetch alerts by fetching all alerts then filtering the result down to the relevant routes. I realized we could start with fewer alerts by using the existing Alerts.Repo.by_route_types/2 function. So that's what the final commit does.

Screenshots

No change!

How to test

Compare with the current commuter rail status -- should work exactly the same way.

@thecristen
thecristen marked this pull request as ready for review July 30, 2026 19:26
@thecristen
thecristen requested a review from a team as a code owner July 30, 2026 19:26
@thecristen
thecristen requested a review from joshlarson July 30, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant