Add Purge.reset!/2 variant allowing to set arbitrary cutoff time

This commit is contained in:
Adrian Gruntkowski 2024-04-22 17:52:33 +02:00
parent b2cd26b262
commit 6f294d5d58

View File

@ -89,6 +89,7 @@ defmodule Plausible.Purge do
:ok
end
@spec reset!(Plausible.Site.t()) :: {:ok, Plausible.Site.t()}
def reset!(site) do
site
|> Ecto.Changeset.change(
@ -97,4 +98,14 @@ defmodule Plausible.Purge do
)
|> Plausible.Repo.update!()
end
@spec reset!(Plausible.Site.t(), NaiveDateTime.t()) :: {:ok, Plausible.Site.t()}
def reset!(site, timestap) do
site
|> Ecto.Changeset.change(
native_stats_start_at: timestamp |> NaiveDateTime.truncate(:second),
stats_start_date: nil
)
|> Plausible.Repo.update!()
end
end