Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rorymckinley committed Nov 21, 2023
1 parent 7c7f32f commit 8a0199c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/lightning/maintenance/admin_tools.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Lightning.AdminTools do
def generate_iso_weeks(start_date, end_date) do
Date.range(start_date, end_date)
|> Enum.map(&Timex.beginning_of_week(&1, :mon))
|> Enum.map(&Date.beginning_of_week(&1))
|> Enum.uniq()
|> Enum.map(fn date ->
{year, week} = Timex.iso_week(date)
Expand All @@ -10,7 +10,7 @@ defmodule Lightning.AdminTools do
year |> Integer.to_string(),
week |> Integer.to_string() |> String.pad_leading(2, "0"),
date |> Date.to_string(),
date |> Timex.shift(weeks: 1) |> Date.to_string()
date |> Date.add(7) |> Date.to_string()
}
end)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/lightning/maintenance/partition_table_service.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ defmodule Lightning.PartitionTableService do
@impl Oban.Worker
def perform(%Oban.Job{args: %{"drop_older_than" => %{"weeks" => weeks}}})
when is_integer(weeks) do
upper_bound = Timex.shift(DateTime.utc_now(), weeks: weeks)
upper_bound = DateTime.add(DateTime.utc_now(), weeks * 7, :day)

remove_empty("work_orders", upper_bound)
end
Expand Down
12 changes: 6 additions & 6 deletions test/lightning/maintenance/partition_table_service_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ defmodule Lightning.PartitionTableServiceTest do
test "removes obsolete partitions" do
parent = "work_orders"

now = DateTime.now!("Etc/UTC")
now = DateTime.utc_now()

drop_range_partitions(parent)

Expand Down Expand Up @@ -75,7 +75,7 @@ defmodule Lightning.PartitionTableServiceTest do
end

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

parent = "work_orders"

Expand Down Expand Up @@ -109,7 +109,7 @@ defmodule Lightning.PartitionTableServiceTest do
end

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

parent = "work_orders"

Expand All @@ -129,7 +129,7 @@ defmodule Lightning.PartitionTableServiceTest do
end

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

parent = "work_orders"

Expand All @@ -152,7 +152,7 @@ defmodule Lightning.PartitionTableServiceTest do
test "remove_empty" do
parent = "work_orders"

now = DateTime.now!("Etc/UTC")
now = DateTime.utc_now()

drop_range_partitions(parent)

Expand All @@ -167,7 +167,7 @@ defmodule Lightning.PartitionTableServiceTest do

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

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

Service.remove_empty(parent, weeks_ago)

Expand Down

0 comments on commit 8a0199c

Please sign in to comment.