analytics/lib/workers/clean_email_verification_codes.ex
Uku Taht 8d1039b8ce
Upgrades Oban to v2.6.1 (#967)
* Upgrades Oban to v2.6.1

* Use correct clickhouse_ecto
2021-04-26 11:32:18 +03:00

16 lines
404 B
Elixir

defmodule Plausible.Workers.CleanEmailVerificationCodes do
use Plausible.Repo
use Oban.Worker, queue: :clean_email_verification_codes
@impl Oban.Worker
def perform(_job) do
Repo.update_all(
from(c in "email_verification_codes",
where: not is_nil(c.user_id),
where: c.issued_at < fragment("now() - INTERVAL '4 hours'")
),
set: [user_id: nil]
)
end
end