Custom pruning is not actually needed because an old job cannot exist in the table due to our use of [replace: true] when retrying jobs or walking it through the different phases

This commit is contained in:
Mark Felder 2025-06-27 17:24:02 -07:00
commit a5e11ad110
2 changed files with 2 additions and 29 deletions

View file

@ -1,26 +0,0 @@
defmodule Pleroma.Workers.Cron.ReachabilityPruner do
use Oban.Worker, queue: :background, max_attempts: 1
import Ecto.Query
require Logger
@reachability_worker "Elixir.Pleroma.Workers.ReachabilityWorker"
@prune_days 2
@impl true
def perform(_job) do
cutoff = DateTime.utc_now() |> DateTime.add(-@prune_days * 24 * 60 * 60, :second)
{count, _} =
from(j in Oban.Job,
where: j.worker == @reachability_worker and j.inserted_at < ^cutoff
)
|> Pleroma.Repo.delete_all()
if count > 0 do
Logger.debug(fn -> "Pruned #{count} old ReachabilityWorker jobs." end)
end
:ok
end
end