Skip to content

Commit 8a0199c

Browse files
committed
Review changes
1 parent 7c7f32f commit 8a0199c

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

lib/lightning/maintenance/admin_tools.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Lightning.AdminTools do
22
def generate_iso_weeks(start_date, end_date) do
33
Date.range(start_date, end_date)
4-
|> Enum.map(&Timex.beginning_of_week(&1, :mon))
4+
|> Enum.map(&Date.beginning_of_week(&1))
55
|> Enum.uniq()
66
|> Enum.map(fn date ->
77
{year, week} = Timex.iso_week(date)
@@ -10,7 +10,7 @@ defmodule Lightning.AdminTools do
1010
year |> Integer.to_string(),
1111
week |> Integer.to_string() |> String.pad_leading(2, "0"),
1212
date |> Date.to_string(),
13-
date |> Timex.shift(weeks: 1) |> Date.to_string()
13+
date |> Date.add(7) |> Date.to_string()
1414
}
1515
end)
1616
end

lib/lightning/maintenance/partition_table_service.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ defmodule Lightning.PartitionTableService do
2222
@impl Oban.Worker
2323
def perform(%Oban.Job{args: %{"drop_older_than" => %{"weeks" => weeks}}})
2424
when is_integer(weeks) do
25-
upper_bound = Timex.shift(DateTime.utc_now(), weeks: weeks)
25+
upper_bound = DateTime.add(DateTime.utc_now(), weeks * 7, :day)
2626

2727
remove_empty("work_orders", upper_bound)
2828
end

test/lightning/maintenance/partition_table_service_test.exs

+6-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ defmodule Lightning.PartitionTableServiceTest do
3434
test "removes obsolete partitions" do
3535
parent = "work_orders"
3636

37-
now = DateTime.now!("Etc/UTC")
37+
now = DateTime.utc_now()
3838

3939
drop_range_partitions(parent)
4040

@@ -75,7 +75,7 @@ defmodule Lightning.PartitionTableServiceTest do
7575
end
7676

7777
test "tables_to_add returns tables that do not already exist" do
78-
now = DateTime.now!("Etc/UTC")
78+
now = DateTime.utc_now()
7979

8080
parent = "work_orders"
8181

@@ -109,7 +109,7 @@ defmodule Lightning.PartitionTableServiceTest do
109109
end
110110

111111
test "add_headroom - all" do
112-
now = DateTime.now!("Etc/UTC")
112+
now = DateTime.utc_now()
113113

114114
parent = "work_orders"
115115

@@ -129,7 +129,7 @@ defmodule Lightning.PartitionTableServiceTest do
129129
end
130130

131131
test "add_headroom - parent specified" do
132-
now = DateTime.now!("Etc/UTC")
132+
now = DateTime.utc_now()
133133

134134
parent = "work_orders"
135135

@@ -152,7 +152,7 @@ defmodule Lightning.PartitionTableServiceTest do
152152
test "remove_empty" do
153153
parent = "work_orders"
154154

155-
now = DateTime.now!("Etc/UTC")
155+
now = DateTime.utc_now()
156156

157157
drop_range_partitions(parent)
158158

@@ -167,7 +167,7 @@ defmodule Lightning.PartitionTableServiceTest do
167167

168168
generate_partitions(-6..3, now, parent)
169169

170-
weeks_ago = Timex.shift(DateTime.utc_now(), weeks: -2)
170+
weeks_ago = DateTime.add(DateTime.utc_now(), -2 * 7, :day)
171171

172172
Service.remove_empty(parent, weeks_ago)
173173

0 commit comments

Comments
 (0)