Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Make invitations cleanup worker rely on UTC time (#4610)
Adrian Gruntkowski69819726176f
diff --git a/lib/workers/clean_invitations.ex b/lib/workers/clean_invitations.exindex 17cf841d06..297d005a4b 100644--- a/lib/workers/clean_invitations.ex+++ b/lib/workers/clean_invitations.ex@@ -2,11 +2,17 @@ defmodule Plausible.Workers.CleanInvitations douse Plausible.Repouse Oban.Worker, queue: :clean_invitations+ @cutoff Duration.new!(hour: -48)+@impl Oban.Workerdef perform(_job) do+ cutoff_time =+ NaiveDateTime.utc_now(:second)+ |> NaiveDateTime.shift(@cutoff)+Repo.delete_all(from i in Plausible.Auth.Invitation,- where: i.inserted_at < fragment("now() - INTERVAL '48 hours'")+ where: i.inserted_at < ^cutoff_time):okdiff --git a/test/workers/clean_invitations_test.exs b/test/workers/clean_invitations_test.exsindex 5d6d872f6f..d354b98af3 100644--- a/test/workers/clean_invitations_test.exs+++ b/test/workers/clean_invitations_test.exs@@ -3,8 +3,10 @@ defmodule Plausible.Workers.CleanInvitationsTest doalias Plausible.Workers.CleanInvitationstest "cleans invitation that is more than 48h old" do+ now = NaiveDateTime.utc_now(:second)+insert(:invitation,- inserted_at: Timex.shift(Timex.now(), hours: -49),+ inserted_at: NaiveDateTime.shift(now, hour: -49),site: build(:site),inviter: build(:user))@@ -15,8 +17,10 @@ defmodule Plausible.Workers.CleanInvitationsTest doendtest "does not clean invitation that is less than 48h old" do+ now = NaiveDateTime.utc_now(:second)+insert(:invitation,- inserted_at: Timex.shift(Timex.now(), hours: -47),+ inserted_at: NaiveDateTime.shift(now, hour: -47),site: build(:site),inviter: build(:user))