Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nodejs 24.5.0
erlang 28.0.2
elixir 1.18.4-otp-28
erlang 28.2
elixir 1.19.4-otp-28
5 changes: 0 additions & 5 deletions config/deps/phoenix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ config :phoenix, :gzippable_exts, ~w(.txt .html .js .css .svg)
config :phoenix, :json_library, Poison

if config_env() == :prod do
config :dotcom, :websocket_check_origin, [
"https://*.mbta.com",
"https://*.mbtace.com"
]

config :dotcom,
dev_server?: false

Expand Down
1 change: 1 addition & 0 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ config :dotcom, DotcomWeb.ViewHelpers,
google_tag_manager_auth: System.get_env("GOOGLE_TAG_MANAGER_AUTH"),
google_tag_manager_preview: System.get_env("GOOGLE_TAG_MANAGER_PREVIEW")

config :dotcom, allow_indexing: System.get_env("ALLOW_INDEXING") == "true"
config :dotcom, google_api_key: System.get_env("GOOGLE_API_KEY")

config :recaptcha,
Expand Down
2 changes: 1 addition & 1 deletion deploy/dotcom/dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM hexpm/elixir:1.18.4-erlang-28.0.2-debian-trixie-20250811-slim
FROM hexpm/elixir:1.19.4-erlang-28.2-debian-trixie-20251229-slim

RUN apt-get update && apt-get install -y curl git make build-essential inotify-tools
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
Expand Down
4 changes: 2 additions & 2 deletions deploy/dotcom/prod/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM hexpm/elixir:1.18.4-erlang-28.0.2-alpine-3.22.1 AS builder
FROM hexpm/elixir:1.19.4-erlang-28.2-alpine-3.23.2 AS builder

# ENVS AND ARGS
ENV LANG="C.UTF-8" MIX_ENV="prod"
Expand Down Expand Up @@ -37,7 +37,7 @@ RUN mix compile
RUN mix phx.digest
RUN mix release

FROM hexpm/elixir:1.18.4-erlang-28.0.2-alpine-3.22.1
FROM hexpm/elixir:1.19.4-erlang-28.2-alpine-3.23.2

ENV PORT=4000 MIX_ENV="prod" PHX_SERVER=true TERM=xterm LANG="C.UTF-8" REPLACE_OS_VARS=true

Expand Down
16 changes: 8 additions & 8 deletions lib/alerts/alert.ex
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ defmodule Alerts.Alert do
defp build_struct(keywords), do: struct!(__MODULE__, keywords)

@spec ensure_entity_set(map) :: t()
defp ensure_entity_set(alert) do
%__MODULE__{alert | informed_entity: InformedEntitySet.new(alert.informed_entity)}
defp ensure_entity_set(%__MODULE__{} = alert) do
%{alert | informed_entity: InformedEntitySet.new(alert.informed_entity)}
end

@spec all_types :: [effect]
Expand Down Expand Up @@ -333,13 +333,13 @@ defmodule Alerts.Alert do
end

defimpl Poison.Encoder, for: Alerts.Alert do
def encode(%Alerts.Alert{active_period: active_period_pairs} = alert, options) do
active_period = Enum.map(active_period_pairs, &alert_active_period/1)
def encode(%Alerts.Alert{} = alert, options) do
alert =
Map.update!(alert, :active_period, fn active_period_pairs ->
Enum.map(active_period_pairs, &alert_active_period/1)
end)

Poison.Encoder.Map.encode(
%{alert | active_period: active_period},
options
)
Poison.Encoder.Map.encode(alert, options)
end

@spec alert_active_period(Alerts.Alert.period_pair()) :: [nil | binary]
Expand Down
4 changes: 2 additions & 2 deletions lib/dotcom/alerts/subway/disruptions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ defmodule Dotcom.Alerts.Subway.Disruptions do
# result is then two alerts, both equivalent to the alert passed in,
# except that one has a single active period of {Sun, Tue}, and the
# other has a single active period of {Thu, Fri}.
defp split_by_discontiguous_active_periods(alert) do
defp split_by_discontiguous_active_periods(%Alerts.Alert{} = alert) do
alert.active_period
|> combine_contiguous_active_periods()
|> Enum.map(fn active_period ->
%Alerts.Alert{alert | active_period: [active_period]}
%{alert | active_period: [active_period]}
end)
end

Expand Down
39 changes: 5 additions & 34 deletions lib/dotcom/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,8 @@ defmodule Dotcom.Application do

# See http://elixir-lang.org/docs/stable/elixir/Application.html
# for more information on OTP Applications
@impl Application
def start(_type, _args) do
Application.put_env(
:dotcom,
:allow_indexing,
DotcomWeb.ControllerHelpers.environment_allows_indexing?()
)

# hack to pull the STATIC_SCHEME variable out of the environment
Application.put_env(
:dotcom,
DotcomWeb.Endpoint,
update_static_url(Application.get_env(:dotcom, DotcomWeb.Endpoint))
)

children =
[
{Application.get_env(:dotcom, :cache, Dotcom.Cache.Multilevel), []},
Expand Down Expand Up @@ -61,12 +49,10 @@ defmodule Dotcom.Application do
[
Routes.Supervisor,
Predictions.Supervisor,
{Phoenix.PubSub, name: Dotcom.PubSub},
Alerts.BusStopChangeSupervisor,
Alerts.CacheSupervisor
] ++
[
{DotcomWeb.Endpoint, name: DotcomWeb.Endpoint}
Alerts.CacheSupervisor,
{Phoenix.PubSub, name: Dotcom.PubSub},
DotcomWeb.Endpoint
] ++
if Application.get_env(:dotcom, :env) != :test do
[
Expand All @@ -85,24 +71,9 @@ defmodule Dotcom.Application do

# Tell Phoenix to update the endpoint configuration
# whenever the application is updated.
@impl Application
def config_change(changed, _new, removed) do
DotcomWeb.Endpoint.config_change(changed, removed)
:ok
end

defp update_static_url([{:static_url, static_url_parts} | rest]) do
static_url_parts = Keyword.update(static_url_parts, :scheme, nil, &update_static_url_scheme/1)
[{:static_url, static_url_parts} | update_static_url(rest)]
end

defp update_static_url([first | rest]) do
[first | update_static_url(rest)]
end

defp update_static_url([]) do
[]
end

defp update_static_url_scheme({:system, env_var}), do: System.get_env(env_var)
defp update_static_url_scheme(scheme), do: scheme
end
4 changes: 2 additions & 2 deletions lib/dotcom/trip_plan/open_street_map_reconciler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ defmodule Dotcom.TripPlan.OpenStreetMapReconciler do
"""
@spec reconcile(InputForm.t()) :: InputForm.t()
@spec reconcile(arg) :: arg when arg: var
def reconcile(%{from: from, to: to} = form) do
%InputForm{form | from: reconcile_location(from), to: reconcile_location(to)}
def reconcile(%InputForm{from: from, to: to} = form) do
%{form | from: reconcile_location(from), to: reconcile_location(to)}
end

def reconcile(form), do: form
Expand Down
2 changes: 1 addition & 1 deletion lib/dotcom_web/controllers/cache_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ defmodule DotcomWeb.CacheController do
}
end)

assigns = assign(assigns, links: links)
assigns = Phoenix.Controller.assign(assigns, links: links)

~H"""
<ul>
Expand Down
5 changes: 0 additions & 5 deletions lib/dotcom_web/controllers/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,6 @@ defmodule DotcomWeb.ControllerHelpers do
end
end

@spec environment_allows_indexing?() :: boolean()
def environment_allows_indexing? do
System.get_env("ALLOW_INDEXING") == "true"
end

@spec filter_alerts_by_direction([Alert.t()], boolean, String.t() | number | nil) :: [Alert.t()]
defp filter_alerts_by_direction(alerts, false, _), do: alerts
defp filter_alerts_by_direction(alerts, true, nil), do: alerts
Expand Down
4 changes: 2 additions & 2 deletions lib/dotcom_web/controllers/schedule/line/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ defmodule DotcomWeb.ScheduleController.Line.Helpers do

@spec do_nil_out_shared_stop_branches([RouteStop.t()], MapSet.t(Stop.id_t())) :: [RouteStop.t()]
defp do_nil_out_shared_stop_branches(route_pattern_group, shared_ids) do
Enum.map(route_pattern_group, fn route_stop ->
Enum.map(route_pattern_group, fn %RouteStop{} = route_stop ->
if MapSet.member?(shared_ids, route_stop.id) do
%RouteStop{
%{
route_stop
| branch: nil
}
Expand Down
8 changes: 1 addition & 7 deletions lib/dotcom_web/endpoint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ defmodule DotcomWeb.Endpoint do
signing_salt: "TInvb4GN",
secure: true

socket(
"/socket",
DotcomWeb.UserSocket,
websocket: [check_origin: Application.compile_env(:dotcom, :websocket_check_origin, false)],
longpoll: [check_origin: Application.compile_env(:dotcom, :websocket_check_origin, false)]
)

socket("/socket", DotcomWeb.UserSocket)
socket("/live", Phoenix.LiveView.Socket, websocket: [connect_info: [session: @session_options]])

# Serve at "/" the static files from "priv/static" directory.
Expand Down
4 changes: 2 additions & 2 deletions lib/location_service/address.ex
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ defmodule LocationService.Address do
@spec parse_label(String.t(), %__MODULE__{}) :: %__MODULE__{}
defp parse_label("", address), do: address

defp parse_label(label, address) do
defp parse_label(label, %__MODULE__{} = address) do
%AddressUS.Address{
street: %AddressUS.Street{
name: street_name,
Expand All @@ -62,7 +62,7 @@ defmodule LocationService.Address do
|> String.trim()
|> with_place_name(label)

%__MODULE__{address | street_address: street_address, municipality: city, state: state}
%{address | street_address: street_address, municipality: city, state: state}
rescue
_ ->
# Remove first section of label, try again!
Expand Down
4 changes: 2 additions & 2 deletions lib/predictions/repo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ defmodule Predictions.Repo do

defp has_departure_time?(
{_id, _trip_id, _stop_id, _route_id, _direction_id, _arrival, departure, _time,
_stop_sequence, _schedule_relationship, _track, _status, _departing?,
_vehicle_id} = _prediction
_stop_sequence, _schedule_relationship, _track, _status, _departing?, _vehicle_id} =
_prediction
) do
departure != nil
end
Expand Down
4 changes: 2 additions & 2 deletions lib/stops/route_stop.ex
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ defmodule Stops.RouteStop do
{first_last, first_body} = List.pop_at(first, -1)

first_body ++
[%RouteStop{first_last | terminus?: false}] ++
(second |> tl() |> Enum.map(&%RouteStop{&1 | branch: branch(first)}))
[%{first_last | terminus?: false}] ++
(second |> tl() |> Enum.map(&%{&1 | branch: branch(first)}))
end

@spec branch([RouteStop.t()]) :: RouteStop.branch_name_t()
Expand Down
23 changes: 14 additions & 9 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ defmodule DotCom.Mixfile do
# used by `mix app.start` to start the application and children in permanent mode, which guarantees the node will shut down if the application terminates (typically because its root supervisor has terminated).
start_permanent: Mix.env() == :prod,
test_coverage: [tool: ExCoveralls],
preferred_cli_env: [
coveralls: :test,
"coveralls.html": :test,
"gettext.extract": :prod,
"gettext.translate": :prod
],
dialyzer: [
plt_add_apps: [:mix, :phoenix_live_reload, :mbta_metro],
flags: [:unmatched_returns]
Expand All @@ -36,6 +30,17 @@ defmodule DotCom.Mixfile do
]
end

def cli do
[
preferred_envs: [
coveralls: :test,
"coveralls.html": :test,
"gettext.extract": :prod,
"gettext.translate": :prod
]
]
end

# Specifies which paths to compile per environment.
defp elixirc_paths(:dev),
do: [
Expand All @@ -60,7 +65,7 @@ defmodule DotCom.Mixfile do
if Mix.env() == :prod do
[:sasl | extra_apps]
else
extra_apps
[:wx, :observer | extra_apps]
end

[
Expand Down Expand Up @@ -94,7 +99,7 @@ defmodule DotCom.Mixfile do
{:csv, "3.2.2"},
{:cva, "0.2.2"},
{:decorator, "1.4.0"},
{:dialyxir, "1.4.6", [only: [:dev, :test], runtime: false]},
{:dialyxir, "1.4.7", [only: [:dev, :test], runtime: false]},
{:diskusage_logger, "0.2.0"},
{:ecto, "3.13.4"},
{:eextoheex, git: "https://github.com/Multiverse-io/eextoheex", only: [:dev, :test]},
Expand Down Expand Up @@ -135,7 +140,7 @@ defmodule DotCom.Mixfile do
[github: "mbta/open_trip_planner_client", tag: "v0.17.1"]
},
{:parallel_stream, "1.1.0"},
{:phoenix, "1.8.1", override: true},
{:phoenix, "1.8.3", override: true},
{:phoenix_ecto, "4.6.5"},
{:phoenix_html_helpers, "1.0.1"},
{:phoenix_live_dashboard, "0.8.7"},
Expand Down
Loading