Skip to content

Commit

Permalink
Upgrade dependencies 2024 07 (#2131)
Browse files Browse the repository at this point in the history
* update all deps except timex

* tests

* dont set env limits until upstream dep does
  • Loading branch information
anthonyshull authored Jul 23, 2024
1 parent 13b5db7 commit 2071866
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 47 deletions.
4 changes: 4 additions & 0 deletions lib/feedback/mailer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ defmodule Feedback.Mailer do
end
end

def formatted_utc_timestamp(%Timex.AmbiguousDateTime{after: aft}) do
formatted_utc_timestamp(aft)
end

def formatted_utc_timestamp(date) do
date
|> Timex.Timezone.convert("Etc/UTC")
Expand Down
8 changes: 4 additions & 4 deletions lib/util/util.ex
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ defmodule Util do
@spec convert_using_timezone(NaiveDateTime.t(), String.t()) :: DateTime.t()
def convert_using_timezone(time, time_zone) do
tz =
if Timex.is_valid_timezone?(time_zone) do
if Timex.Timezone.exists?(time_zone) do
time_zone
else
"America/New_York"
end

time
|> Timex.to_datetime(tz)
|> Timex.Timezone.convert(tz)
|> handle_ambiguous_time()
end

Expand Down Expand Up @@ -188,10 +188,10 @@ defmodule Util do

@spec handle_ambiguous_time(Timex.AmbiguousDateTime.t() | DateTime.t() | {:error, any}) ::
DateTime.t() | {:error, any}
defp handle_ambiguous_time(%Timex.AmbiguousDateTime{before: before}) do
defp handle_ambiguous_time(%Timex.AmbiguousDateTime{after: aft}) do
# ambiguous time only happens between midnight and 3am
# during November daylight saving transition
before
aft
end

defp handle_ambiguous_time(%DateTime{} = time) do
Expand Down
24 changes: 12 additions & 12 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ defmodule DotCom.Mixfile do
{:ex_aws, "2.5.4"},
{:ex_aws_s3, "2.5.3"},
{:ex_aws_ses, "2.4.1"},
{:ex_doc, "0.34.0", only: :dev},
{:ex_machina, "2.7.0"},
{:ex_doc, "0.34.2", only: :dev},
# we can't make this [:dev, :test] only until `open_trip_planner_client` is updated
{:ex_machina, "2.8.0", override: true},
{:ex_unit_summary, "0.1.0", only: [:dev, :test]},
# latest version 0.18.1; cannot upgrade because expects castore >= 1
{:excoveralls, "0.16.1", only: :test},
Expand All @@ -103,21 +104,21 @@ defmodule DotCom.Mixfile do
{:mail, "0.3.1"},
{:mock, "0.3.8", [only: :test]},
{:mox, "1.1.0", [only: :test]},
{:nebulex, "2.6.1"},
{:nebulex, "2.6.2"},
{:nebulex_redis_adapter, "2.4.0"},
{:open_trip_planner_client, [github: "thecristen/open_trip_planner_client", tag: "v0.9.1"]},
{:parallel_stream, "1.1.0"},
# latest version 1.7.12
# latest version 1.7.14
{:phoenix, "1.6.16"},
# latest version 4.1.1; cannot upgrade because we use Phoenix.HTML
{:phoenix_html, "3.3.3"},
{:phoenix_live_dashboard, "0.8.4"},
{:phoenix_live_reload, "1.5.3", [only: :dev]},
{:phoenix_live_view, "0.20.16"},
{:phoenix_live_view, "0.20.17"},
{:phoenix_pubsub, "2.1.3"},
{:plug, "1.16.0"},
{:plug, "1.16.1"},
{:plug_cowboy, "2.7.1"},
# latest version is 5.0.0; cannot upgrade because we use Poison.Parser.parse!
# latest version is 6.0.0; cannot upgrade because we use Poison.Parser.parse!
{:poison, "3.1.0"},
{:polyline, "1.4.0"},
{:poolboy, "1.5.2"},
Expand All @@ -130,10 +131,10 @@ defmodule DotCom.Mixfile do
github: "samueljseay/recaptcha",
ref: "8ea13f63990ca18725ac006d30e55d42c3a58457"
]},
{:recase, "0.8.0"},
{:recase, "0.8.1"},
{:recon, "2.5.5", [only: :prod]},
{:redix, "1.5.1"},
{:req, "0.5.0", override: true},
{:req, "0.5.4", override: true},
{:rstar, github: "armon/erl-rstar"},
# latest version 10.1.0; cannot upgrade because setup appears to have changed
{:sentry, "7.2.5"},
Expand All @@ -145,12 +146,11 @@ defmodule DotCom.Mixfile do
{:telemetry_metrics_splunk, "0.0.6-alpha"},
{:telemetry_poller, "1.1.0"},
{:telemetry_test, "0.1.2", only: [:test]},
# latest version is 3.7.11; cannot upgrade because tests fail
{:timex, "3.1.24"},
{:timex, "3.7.11"},
{:unrooted_polytree, "0.1.1"},
{:uuid, "1.1.8"},
{:wallaby, "0.30.9", [runtime: false, only: [:test, :dev]]},
{:yaml_elixir, "2.9.0", only: [:dev]},
{:yaml_elixir, "2.11.0", only: [:dev]},
{:ymlr, "5.1.3", only: [:dev]}
]
end
Expand Down
28 changes: 14 additions & 14 deletions mix.lock

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions test/alerts/parser_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@ defmodule Alerts.ParserTest do
]),
active_period: [
{~N[2016-06-06T14:48:48]
|> Timex.to_datetime("Etc/GMT+4")
|> Timex.Timezone.convert("America/New_York"),
~N[2016-06-06T19:53:51]
|> Timex.to_datetime("Etc/GMT+4")
|> Timex.Timezone.convert("America/New_York")}
],
banner: "Test banner copy",
Expand All @@ -72,7 +70,6 @@ defmodule Alerts.ParserTest do
cause: :traffic,
updated_at:
~N[2016-06-20T16:09:29]
|> Timex.to_datetime("Etc/GMT+4")
|> Timex.Timezone.convert("America/New_York"),
description: "Affected routes: 18",
priority: :low,
Expand Down
2 changes: 1 addition & 1 deletion test/dotcom_web/views/cms_view_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ defmodule DotcomWeb.CMSViewTest do
)

# could also be November 6th, 1:00 AM (test daylight savings)
expected = "November 5, 2016 1 AM - November 6, 2016 2 AM"
expected = "November 5, 2016 1 AM - November 6, 2016 1 AM"
assert expected == actual
end

Expand Down
2 changes: 1 addition & 1 deletion test/dotcom_web/views/event_view_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ defmodule DotcomWeb.EventViewTest do
)

# could also be November 6th, 1:00 AM (test daylight savings)
expected = "Sat, Nov 5, 2016 1 AM - Sun, Nov 6, 2016 2 AM"
expected = "Sat, Nov 5, 2016 1 AM - Sun, Nov 6, 2016 1 AM"
assert expected == actual
end

Expand Down
6 changes: 5 additions & 1 deletion test/dotcom_web/views/schedule/timetable_view_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ defmodule DotcomWeb.Schedule.TimetableViewTest do
header_schedules = [%Schedules.Schedule{trip: trip}]

trip_schedules = %{
{"Test-Trip-ID", "Test-Stop-ID"} => %Schedules.Schedule{trip: trip, stop: original_stop}
{"Test-Trip-ID", "Test-Stop-ID"} => %Schedules.Schedule{
stop: original_stop,
time: Timex.now(),
trip: trip
}
}

assigns =
Expand Down
6 changes: 3 additions & 3 deletions test/feedback/mailer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,13 @@ defmodule Feedback.MailerTest do
end

test "converts 'America/New_York' date to UTC accounting for beginning of daylight saving time" do
dt = Util.convert_using_timezone(~N[2020-03-08T02:00:00], "America/New_York")
assert Mailer.formatted_utc_timestamp(dt) == "03/08/2020 06:00"
dt = Util.convert_using_timezone(~N[2020-03-08T03:00:00], "America/New_York")
assert Mailer.formatted_utc_timestamp(dt) == "03/08/2020 07:00"
end

test "converts 'America/New_York' date to UTC accounting for end of daylight saving time" do
dt = Util.convert_using_timezone(~N[2020-11-01T01:00:00], "America/New_York")
assert Mailer.formatted_utc_timestamp(dt) == "11/01/2020 05:00"
assert Mailer.formatted_utc_timestamp(dt) == "11/01/2020 06:00"
end
end
end
16 changes: 8 additions & 8 deletions test/util/util_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defmodule UtilTest do
test "handles ambiguous UTC times by returning the earlier time" do
for {time, expected} <- [
{~N[2016-11-06T05:00:00], "2016-11-06T01:00:00-04:00"},
{~N[2016-11-06T06:00:00], "2016-11-06T02:00:00-04:00"},
{~N[2016-11-06T06:00:00], "2016-11-06T01:00:00-05:00"},
{~N[2016-11-06T07:00:00], "2016-11-06T02:00:00-05:00"}
] do
utc_fn = fn "America/New_York" -> Timex.set(time, timezone: "UTC") end
Expand All @@ -37,7 +37,7 @@ defmodule UtilTest do
assert %DateTime{month: 11, day: 4, hour: 1, zone_abbr: "EDT"} =
Util.to_local_time(~N[2018-11-04T05:00:00])

assert %DateTime{month: 11, day: 4, hour: 2, zone_abbr: "EDT"} =
assert %DateTime{month: 11, day: 4, hour: 1, zone_abbr: "EST"} =
Util.to_local_time(~N[2018-11-04T06:00:00])

assert %DateTime{month: 11, day: 4, hour: 2, zone_abbr: "EST"} =
Expand All @@ -52,10 +52,10 @@ defmodule UtilTest do
end

test "handles Timex.AmbiguousDateTime.t" do
before_date = Util.to_local_time(~N[2018-11-04T05:00:00])
before_date = Util.to_local_time(~N[2018-11-04T04:00:00])
after_date = Util.to_local_time(~N[2018-11-04T06:00:00])

assert before_date ==
assert after_date ==
Util.to_local_time(%Timex.AmbiguousDateTime{after: after_date, before: before_date})
end
end
Expand Down Expand Up @@ -87,7 +87,7 @@ defmodule UtilTest do
ambiguous = Timex.to_datetime({{2020, 11, 1}, {1, 0, 0}}, "America/New_York")

assert Util.convert_using_timezone(~N[2020-11-01T01:00:00], "America/New_York") ==
ambiguous.before
ambiguous.after
end
end

Expand Down Expand Up @@ -142,7 +142,7 @@ defmodule UtilTest do
# 2am EDT / 1am EST
assert Util.service_date(~N[2018-11-04T06:00:00]) == ~D[2018-11-03]
# 2am EST
assert Util.service_date(~N[2018-11-04T07:00:00]) == ~D[2018-11-03]
assert Util.service_date(~N[2018-11-04T07:00:00]) == ~D[2018-11-04]
# 3am EST
assert Util.service_date(~N[2018-11-04T08:00:00]) == ~D[2018-11-04]
# 4am EST
Expand Down Expand Up @@ -222,7 +222,7 @@ defmodule UtilTest do
# 2am EST
assert ~N[2018-11-04T07:00:00]
|> Util.to_local_time()
|> Util.service_date() == ~D[2018-11-03]
|> Util.service_date() == ~D[2018-11-04]

# 3am EST
assert ~N[2018-11-04T08:00:00]
Expand Down Expand Up @@ -308,7 +308,7 @@ defmodule UtilTest do
# 2am EST
assert ~N[2018-11-04T07:00:00]
|> DateTime.from_naive!("Etc/UTC")
|> Util.service_date() == ~D[2018-11-03]
|> Util.service_date() == ~D[2018-11-04]

# 3am EST
assert ~N[2018-11-04T08:00:00]
Expand Down

0 comments on commit 2071866

Please sign in to comment.