analytics/lib/workers/expire_domain_change_transitions.ex
hq1 1d01328287
Allow domain change (#2803)
* Migration (PR: https://github.com/plausible/analytics/pull/2802)

* Implement Site.Domain interface allowing change and expiry

* Fixup seeds so they work with V2_MIGRATION_DONE=1

* Update Sites.Cache so it's capable of multi-keyed lookups

* Implement worker handling domain change expiration

* Implement domain change UI

* Implement transition period for public APIs

* Exclude v2 tests in primary test run

* Update lib/plausible_web/controllers/site_controller.ex

Co-authored-by: Vini Brasil <vini@hey.com>

* Update lib/plausible_web/controllers/site_controller.ex

Co-authored-by: Vini Brasil <vini@hey.com>

* Update moduledoc

* Update changelog

* Remove remnant from previous implementation attempt

* !fixup

* !fixup

* Implement domain change via Sites API

cc @ukutaht

* Update CHANGELOG

* Credo

* !fixup commit missing tests

* Allow continuous domain change within the same site

---------

Co-authored-by: Vini Brasil <vini@hey.com>
2023-04-04 10:55:12 +02:00

23 lines
598 B
Elixir

defmodule Plausible.Workers.ExpireDomainChangeTransitions do
@moduledoc """
Periodic worker that expires domain change transition period.
Old domains are frozen for a given time, so users can still access them
before redeploying their scripts and integrations.
"""
use Plausible.Repo
use Oban.Worker, queue: :domain_change_transition
require Logger
@impl Oban.Worker
def perform(_job) do
{:ok, n} = Plausible.Site.Domain.expire_change_transitions()
if n > 0 do
Logger.warning("Expired #{n} from the domain change transition period.")
end
:ok
end
end