Skip to content

Commit

Permalink
feature: increase deletion date to 24 months #127 (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwittstruck authored Jul 3, 2024
1 parent c1059dd commit 272c6b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/wordcharts/worker/remove_charts_worker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Wordcharts.Worker.RemoveChartsWorker do

@impl Oban.Worker
def perform(_job) do
days = 30
days = 720

Charts.delete_charts_older_than(days)

Expand Down
10 changes: 7 additions & 3 deletions test/worker/remove_charts_worker_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,23 @@ defmodule Wordcharts.RemoveChartsWorkerTest do
{:ok, uuid_as_binary} = UUID.dump(chart.id)

query = "UPDATE charts SET updated_at = $1 WHERE id = $2"
Ecto.Adapters.SQL.query!(Repo, query, [Timex.shift(Timex.now(), days: -31), uuid_as_binary])

Ecto.Adapters.SQL.query!(Repo, query, [Timex.shift(Timex.now(), days: -721), uuid_as_binary])

chart
end

def mark_words_overdue(chart) do
{:ok, uuid_as_binary} = UUID.dump(chart.id)

query = "UPDATE words SET updated_at = $1 WHERE chart_id = $2"
Ecto.Adapters.SQL.query!(Repo, query, [Timex.shift(Timex.now(), days: -31), uuid_as_binary])

Ecto.Adapters.SQL.query!(Repo, query, [Timex.shift(Timex.now(), days: -721), uuid_as_binary])

chart
end

test "perform/1 deletes charts older than thirty days" do
test "perform/1 deletes charts older than 720 days" do
empty_active_chart = empty_active_chart()
empty_overdue_chart = empty_overdue_chart()
assert :ok = perform_job(Wordcharts.Worker.RemoveChartsWorker, %{})
Expand Down

0 comments on commit 272c6b9

Please sign in to comment.