Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Upgrades Oban to v2.6.1 (#967)

Uku Taht8d1039b8ce59
diff --git a/config/runtime.exs b/config/runtime.exs
index 62b92f4717..836e7c9345 100644
--- a/config/runtime.exs
+++ b/config/runtime.exs
@@ -220,17 +220,17 @@ if config_env() == :prod && !disable_cron do
notify_annual_renewal: 1
]
+ # Keep 30 days history
config :plausible, Oban,
- # Keep 30 days history
- prune: {:maxage, 2_592_000},
repo: Plausible.Repo,
+ plugins: [{Oban.Plugins.Pruner, max_age: 2_592_000}],
queues: if(is_selfhost, do: base_queues, else: base_queues ++ extra_queues),
crontab: if(is_selfhost, do: base_cron, else: base_cron ++ extra_cron)
else
config :plausible, Oban,
repo: Plausible.Repo,
queues: false,
- crontab: false
+ plugins: false
end
config :plausible, :hcaptcha,
diff --git a/lib/plausible/application.ex b/lib/plausible/application.ex
index 423f9383a9..97d96c324a 100644
--- a/lib/plausible/application.ex
+++ b/lib/plausible/application.ex
@@ -21,7 +21,7 @@ defmodule Plausible.Application do
]
opts = [strategy: :one_for_one, name: Plausible.Supervisor]
- Logger.add_backend(Sentry.LoggerBackend)
+ setup_sentry()
setup_cache_stats()
Application.put_env(:plausible, :server_start, Timex.now())
Supervisor.start_link(children, opts)
@@ -40,6 +40,17 @@ defmodule Plausible.Application do
end
end
+ def setup_sentry() do
+ Logger.add_backend(Sentry.LoggerBackend)
+
+ :telemetry.attach_many(
+ "oban-errors",
+ [[:oban, :job, :exception], [:oban, :circuit, :trip]],
+ &ErrorReporter.handle_event/4,
+ %{}
+ )
+ end
+
def report_cache_stats() do
case Cachex.stats(:user_agents) do
{:ok, stats} ->
diff --git a/lib/telemetry.ex b/lib/telemetry.ex
new file mode 100644
index 0000000000..b9dd8c7c09
--- /dev/null
+++ b/lib/telemetry.ex
@@ -0,0 +1,14 @@
+defmodule ErrorReporter do
+ def handle_event([:oban, :job, :exception], measure, %{job: job} = meta, _) do
+ extra =
+ job
+ |> Map.take([:id, :args, :meta, :queue, :worker])
+ |> Map.merge(measure)
+
+ Sentry.capture_exception(meta.error, stacktrace: meta.stacktrace, extra: extra)
+ end
+
+ def handle_event([:oban, :circuit, :trip], _measure, meta, _) do
+ Sentry.capture_exception(meta.error, stacktrace: meta.stacktrace, extra: meta)
+ end
+end
diff --git a/lib/workers/check_usage.ex b/lib/workers/check_usage.ex
index ea021c95d9..e1b4b4208d 100644
--- a/lib/workers/check_usage.ex
+++ b/lib/workers/check_usage.ex
@@ -30,7 +30,7 @@ defmodule Plausible.Workers.CheckUsage do
end
@impl Oban.Worker
- def perform(_args, _job, billing_mod \\ Plausible.Billing, today \\ Timex.today()) do
+ def perform(_job, billing_mod \\ Plausible.Billing, today \\ Timex.today()) do
yesterday = today |> Timex.shift(days: -1)
active_subscribers =
diff --git a/lib/workers/clean_email_verification_codes.ex b/lib/workers/clean_email_verification_codes.ex
index 5b7af9272b..9ef851635d 100644
--- a/lib/workers/clean_email_verification_codes.ex
+++ b/lib/workers/clean_email_verification_codes.ex
@@ -3,7 +3,7 @@ defmodule Plausible.Workers.CleanEmailVerificationCodes do
use Oban.Worker, queue: :clean_email_verification_codes
@impl Oban.Worker
- def perform(_args, _job) do
+ def perform(_job) do
Repo.update_all(
from(c in "email_verification_codes",
where: not is_nil(c.user_id),
diff --git a/lib/workers/fetch_tweets.ex b/lib/workers/fetch_tweets.ex
index bf67149508..5b9ddbad18 100644
--- a/lib/workers/fetch_tweets.ex
+++ b/lib/workers/fetch_tweets.ex
@@ -4,7 +4,7 @@ defmodule Plausible.Workers.FetchTweets do
use Oban.Worker, queue: :fetch_tweets
@impl Oban.Worker
- def perform(_args, _job, twitter_api \\ Plausible.Twitter.Api) do
+ def perform(_job, twitter_api \\ Plausible.Twitter.Api) do
new_links =
Plausible.ClickhouseRepo.all(
from e in Plausible.ClickhouseEvent,
diff --git a/lib/workers/notify_annual_renewal.ex b/lib/workers/notify_annual_renewal.ex
index 25666a8b90..77d5240fd7 100644
--- a/lib/workers/notify_annual_renewal.ex
+++ b/lib/workers/notify_annual_renewal.ex
@@ -8,7 +8,7 @@ defmodule Plausible.Workers.NotifyAnnualRenewal do
@doc """
Sends a notification at most 7 days and at least 1 day before the renewal of an annual subscription
"""
- def perform(_args, _job) do
+ def perform(_job) do
users =
Repo.all(
from u in Plausible.Auth.User,
diff --git a/lib/workers/provision_ssl_certificates.ex b/lib/workers/provision_ssl_certificates.ex
index cdc37483be..48873eb003 100644
--- a/lib/workers/provision_ssl_certificates.ex
+++ b/lib/workers/provision_ssl_certificates.ex
@@ -5,7 +5,7 @@ defmodule Plausible.Workers.ProvisionSslCertificates do
@timeout 20_000
@impl Oban.Worker
- def perform(_args, _job, ssh \\ SSHEx) do
+ def perform(_job, ssh \\ SSHEx) do
config = get_config()
{:ok, conn} =
diff --git a/lib/workers/rotate_salts.ex b/lib/workers/rotate_salts.ex
index 8cde113892..7bc0d1effa 100644
--- a/lib/workers/rotate_salts.ex
+++ b/lib/workers/rotate_salts.ex
@@ -3,7 +3,7 @@ defmodule Plausible.Workers.RotateSalts do
use Oban.Worker, queue: :rotate_salts
@impl Oban.Worker
- def perform(_args, _job) do
+ def perform(_job) do
Plausible.Session.Salts.rotate()
end
end
diff --git a/lib/workers/schedule_email_reports.ex b/lib/workers/schedule_email_reports.ex
index 4ff34084c8..5c87daec49 100644
--- a/lib/workers/schedule_email_reports.ex
+++ b/lib/workers/schedule_email_reports.ex
@@ -10,7 +10,7 @@ defmodule Plausible.Workers.ScheduleEmailReports do
of a site. This job runs every day at midnight to ensure that all sites
have a scheduled job for email reports.
"""
- def perform(_args, _job) do
+ def perform(_job) do
schedule_weekly_emails()
schedule_monthly_emails()
end
diff --git a/lib/workers/send_check_stats_emails.ex b/lib/workers/send_check_stats_emails.ex
index b1577452b9..e01ef45ee3 100644
--- a/lib/workers/send_check_stats_emails.ex
+++ b/lib/workers/send_check_stats_emails.ex
@@ -3,7 +3,7 @@ defmodule Plausible.Workers.SendCheckStatsEmails do
use Oban.Worker, queue: :check_stats_emails
@impl Oban.Worker
- def perform(_args, _job) do
+ def perform(_job) do
q =
from(u in Plausible.Auth.User,
left_join: ce in "check_stats_emails",
diff --git a/lib/workers/send_email_report.ex b/lib/workers/send_email_report.ex
index 3621fe1f79..8b63ab0c2d 100644
--- a/lib/workers/send_email_report.ex
+++ b/lib/workers/send_email_report.ex
@@ -5,7 +5,7 @@ defmodule Plausible.Workers.SendEmailReport do
alias Plausible.Stats.Clickhouse, as: Stats
@impl Oban.Worker
- def perform(%{"interval" => "weekly", "site_id" => site_id}, _job) do
+ def perform(%Oban.Job{args: %{"interval" => "weekly", "site_id" => site_id}}) do
site = Repo.get(Plausible.Site, site_id) |> Repo.preload(:weekly_report)
today = Timex.now(site.timezone) |> DateTime.to_date()
date = Timex.shift(today, weeks: -1) |> Timex.end_of_week() |> Date.to_iso8601()
@@ -23,7 +23,7 @@ defmodule Plausible.Workers.SendEmailReport do
end
@impl Oban.Worker
- def perform(%{"interval" => "monthly", "site_id" => site_id}, _job) do
+ def perform(%Oban.Job{args: %{"interval" => "monthly", "site_id" => site_id}}) do
site = Repo.get(Plausible.Site, site_id) |> Repo.preload(:monthly_report)
last_month =
diff --git a/lib/workers/send_site_setup_emails.ex b/lib/workers/send_site_setup_emails.ex
index 9fc928ed93..92e5f00c04 100644
--- a/lib/workers/send_site_setup_emails.ex
+++ b/lib/workers/send_site_setup_emails.ex
@@ -5,7 +5,7 @@ defmodule Plausible.Workers.SendSiteSetupEmails do
alias Plausible.Stats.Clickhouse, as: Stats
@impl Oban.Worker
- def perform(_args, _job) do
+ def perform(_job) do
send_create_site_emails()
send_setup_help_emails()
send_setup_success_emails()
diff --git a/lib/workers/send_trial_notifications.ex b/lib/workers/send_trial_notifications.ex
index d93bab4041..ab2e140f45 100644
--- a/lib/workers/send_trial_notifications.ex
+++ b/lib/workers/send_trial_notifications.ex
@@ -8,7 +8,7 @@ defmodule Plausible.Workers.SendTrialNotifications do
require Logger
@impl Oban.Worker
- def perform(_args, _job) do
+ def perform(_job) do
users =
Repo.all(
from u in Plausible.Auth.User,
diff --git a/lib/workers/spike_notifier.ex b/lib/workers/spike_notifier.ex
index 0149eb3e57..a588b29a00 100644
--- a/lib/workers/spike_notifier.ex
+++ b/lib/workers/spike_notifier.ex
@@ -6,7 +6,7 @@ defmodule Plausible.Workers.SpikeNotifier do
@at_most_every "12 hours"
@impl Oban.Worker
- def perform(_args, _job, clickhouse \\ Plausible.Stats.Clickhouse) do
+ def perform(_job, clickhouse \\ Plausible.Stats.Clickhouse) do
notifications =
Repo.all(
from sn in SpikeNotification,
diff --git a/mix.exs b/mix.exs
index 122793bc0c..7eb6af5be3 100644
--- a/mix.exs
+++ b/mix.exs
@@ -83,7 +83,7 @@ defmodule Plausible.MixProject do
{:oauther, "~> 1.1"},
{:nanoid, "~> 2.0.2"},
{:siphash, "~> 3.2"},
- {:oban, "~> 1.2"},
+ {:oban, "~> 2.0"},
{:sshex, "2.2.1"},
{:geolix, "~> 1.0"},
{:clickhouse_ecto, git: "https://github.com/plausible/clickhouse_ecto.git"},
diff --git a/mix.lock b/mix.lock
index 185cfa2a7d..273a6aab17 100644
--- a/mix.lock
+++ b/mix.lock
@@ -12,7 +12,7 @@
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"},
"cachex": {:hex, :cachex, "3.3.0", "6f2ebb8f27491fe39121bd207c78badc499214d76c695658b19d6079beeca5c2", [:mix], [{:eternal, "~> 1.2", [hex: :eternal, repo: "hexpm", optional: false]}, {:jumper, "~> 1.0", [hex: :jumper, repo: "hexpm", optional: false]}, {:sleeplocks, "~> 1.1", [hex: :sleeplocks, repo: "hexpm", optional: false]}, {:unsafe, "~> 1.0", [hex: :unsafe, repo: "hexpm", optional: false]}], "hexpm", "d90e5ee1dde14cef33f6b187af4335b88748b72b30c038969176cd4e6ccc31a1"},
"certifi": {:hex, :certifi, "2.6.1", "dbab8e5e155a0763eea978c913ca280a6b544bfa115633fa20249c3d396d9493", [:rebar3], [], "hexpm", "524c97b4991b3849dd5c17a631223896272c6b0af446778ba4675a1dff53bb7e"},
- "clickhouse_ecto": {:git, "https://github.com/plausible/clickhouse_ecto.git", "b30ccc93a4101a25ff0bba92113e18d8a9a8b28e", []},
+ "clickhouse_ecto": {:git, "https://github.com/plausible/clickhouse_ecto.git", "1969f14ecef7c357b2bd8bdc3e566234269de58c", []},
"clickhousex": {:git, "https://github.com/plausible/clickhousex", "0832dd4b1af1f0eba1d1018c231bf0d8d281f031", []},
"combine": {:hex, :combine, "0.10.0", "eff8224eeb56498a2af13011d142c5e7997a80c8f5b97c499f84c841032e429f", [:mix], [], "hexpm", "1b1dbc1790073076580d0d1d64e42eae2366583e7aecd455d1215b0d16f2451b"},
"comeonin": {:hex, :comeonin, "5.3.2", "5c2f893d05c56ae3f5e24c1b983c2d5dfb88c6d979c9287a76a7feb1e1d8d646", [:mix], [], "hexpm", "d0993402844c49539aeadb3fe46a3c9bd190f1ecf86b6f9ebd71957534c95f04"},
@@ -28,8 +28,8 @@
"decorator": {:hex, :decorator, "1.3.2", "63b8ac9e23b28053390abdda33bb9e1f3dd9e8f9a981f47a06fc2f2fe2e2f772", [:mix], [], "hexpm", "b80bd089e3c8579e6d9ea84eed307b1597a0d94af25331e424a209477ad1a7fc"},
"dialyxir": {:hex, :dialyxir, "1.0.0", "6a1fa629f7881a9f5aaf3a78f094b2a51a0357c843871b8bc98824e7342d00a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "aeb06588145fac14ca08d8061a142d52753dbc2cf7f0d00fc1013f53f8654654"},
"double": {:hex, :double, "0.7.0", "a7ee4c3488a0acc6d2ad9b69b6c7d3ddf3da2b54488d0f7c2d6ceb3a995887ca", [:mix], [], "hexpm", "f0c387a2266b4452da7bab03598feec11aef8b2acab061ea947dae81bb257329"},
- "ecto": {:hex, :ecto, "3.5.5", "48219a991bb86daba6e38a1e64f8cea540cded58950ff38fbc8163e062281a07", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "98dd0e5e1de7f45beca6130d13116eae675db59adfa055fb79612406acf6f6f1"},
- "ecto_sql": {:hex, :ecto_sql, "3.5.3", "1964df0305538364b97cc4661a2bd2b6c89d803e66e5655e4e55ff1571943efd", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.5.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.3.0 or ~> 0.4.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d2f53592432ce17d3978feb8f43e8dc0705e288b0890caf06d449785f018061c"},
+ "ecto": {:hex, :ecto, "3.6.1", "7bb317e3fd0179ad725069fd0fe8a28ebe48fec6282e964ea502e4deccb0bd0f", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "cbb3294a990447b19f0725488a749f8cf806374e0d9d0dffc45d61e7aeaf6553"},
+ "ecto_sql": {:hex, :ecto_sql, "3.6.1", "8774dc3fc0ff7b6be510858b99883640f990c0736b8ab54588f9a0c91807f909", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.6.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.4.0 or ~> 0.5.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "66f35c3f2d5978b6bffebd1e6351ab8c9d6b68650d62abd1ab8d149de40e0779"},
"elixir_make": {:hex, :elixir_make, "0.6.2", "7dffacd77dec4c37b39af867cedaabb0b59f6a871f89722c25b28fcd4bd70530", [:mix], [], "hexpm", "03e49eadda22526a7e5279d53321d1cced6552f344ba4e03e619063de75348d9"},
"elixir_uuid": {:hex, :elixir_uuid, "1.2.1", "dce506597acb7e6b0daeaff52ff6a9043f5919a4c3315abb4143f0b00378c097", [:mix], [], "hexpm", "f7eba2ea6c3555cea09706492716b0d87397b88946e6380898c2889d68585752"},
"envy": {:hex, :envy, "1.1.1", "0bc9bd654dec24fcdf203f7c5aa1b8f30620f12cfb28c589d5e9c38fe1b07475", [:mix], [], "hexpm", "7061eb1a47415fd757145d8dec10dc0b1e48344960265cb108f194c4252c3a89"},
@@ -58,7 +58,7 @@
"mmdb2_decoder": {:hex, :mmdb2_decoder, "3.0.0", "54828676a36e75e9a25bc9a0bb0598d4c7fcc767bf0b40674850b22e05b7b6cc", [:mix], [], "hexpm", "359dc9242915538d1dceb9f6d96c72201dca76ce62e49d22e2ed1e86f20bea8e"},
"nanoid": {:hex, :nanoid, "2.0.5", "1d2948d8967ef2d948a58c3fef02385040bd9823fc6394bd604b8d98e5516b22", [:mix], [], "hexpm", "956e8876321104da72aa48770539ff26b36b744cd26753ec8e7a8a37e53d5f58"},
"oauther": {:hex, :oauther, "1.1.1", "7d8b16167bb587ecbcddd3f8792beb9ec3e7b65c1f8ebd86b8dd25318d535752", [:mix], [], "hexpm", "9374f4302045321874cccdc57eb975893643bd69c3b22bf1312dab5f06e5788e"},
- "oban": {:hex, :oban, "1.2.0", "7cca94d341be43d220571e28f69131c4afc21095b25257397f50973d3fc59b07", [:mix], [{:ecto_sql, "~> 3.1", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.14", [hex: :postgrex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ba5f8b3f7d76967b3e23cf8014f6a13e4ccb33431e4808f036709a7f822362ee"},
+ "oban": {:hex, :oban, "2.6.1", "7466e25934be6c3f696c624ed0779459dd2add03d19f9865a478d3b47b77e814", [:mix], [{:ecto_sql, ">= 3.4.3", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.14", [hex: :postgrex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "3e86eaab8fdd1c1af64f7cfd46ad4352d19696709eb2068de239e40894a254ea"},
"parallel_stream": {:hex, :parallel_stream, "1.0.6", "b967be2b23f0f6787fab7ed681b4c45a215a81481fb62b01a5b750fa8f30f76c", [:mix], [], "hexpm", "639b2e8749e11b87b9eb42f2ad325d161c170b39b288ac8d04c4f31f8f0823eb"},
"parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"},
"phoenix": {:hex, :phoenix, "1.5.8", "71cfa7a9bb9a37af4df98939790642f210e35f696b935ca6d9d9c55a884621a4", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_html, "~> 2.13", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.1.2 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "35ded0a32f4836168c7ab6c33b88822eccd201bcd9492125a9bea4c54332d955"},
@@ -72,7 +72,7 @@
"plug_crypto": {:hex, :plug_crypto, "1.2.2", "05654514ac717ff3a1843204b424477d9e60c143406aa94daf2274fdd280794d", [:mix], [], "hexpm", "87631c7ad914a5a445f0a3809f99b079113ae4ed4b867348dd9eec288cecb6db"},
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm", "fec8660eb7733ee4117b85f55799fd3833eb769a6df71ccf8903e8dc5447cfce"},
"poolboy": {:hex, :poolboy, "1.5.2", "392b007a1693a64540cead79830443abf5762f5d30cf50bc95cb2c1aaafa006b", [:rebar3], [], "hexpm", "dad79704ce5440f3d5a3681c8590b9dc25d1a561e8f5a9c995281012860901e3"},
- "postgrex": {:hex, :postgrex, "0.15.7", "724410acd48abac529d0faa6c2a379fb8ae2088e31247687b16cacc0e0883372", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "88310c010ff047cecd73d5ceca1d99205e4b1ab1b9abfdab7e00f5c9d20ef8f9"},
+ "postgrex": {:hex, :postgrex, "0.15.9", "46f8fe6f25711aeb861c4d0ae09780facfdf3adbd2fb5594ead61504dd489bda", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "610719103e4cb2223d4ab78f9f0f3e720320eeca6011415ab4137ddef730adee"},
"ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm", "451d8527787df716d99dc36162fca05934915db0b6141bbdac2ea8d3c7afc7d7"},
"ref_inspector": {:hex, :ref_inspector, "1.3.1", "bb0489a4c4299dcd633f2b7a60c41a01f5590789d0b28225a60be484e1fbe777", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:yamerl, "~> 0.7", [hex: :yamerl, repo: "hexpm", optional: false]}], "hexpm", "3172eb1b08e5c69966f796e3fe0e691257546fa143a5eb0ecc18a6e39b233854"},
"sentry": {:hex, :sentry, "8.0.5", "5ca922b9238a50c7258b52f47364b2d545beda5e436c7a43965b34577f1ef61f", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: true]}, {:plug, "~> 1.6", [hex: :plug, repo: "hexpm", optional: true]}, {:plug_cowboy, "~> 2.3", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm", "4972839fdbf52e886d7b3e694c8adf421f764f2fa79036b88fb4742049bd4b7c"},
diff --git a/priv/repo/migrations/20210426075157_upgrade_oban_jobs_to_v9.exs b/priv/repo/migrations/20210426075157_upgrade_oban_jobs_to_v9.exs
new file mode 100644
index 0000000000..6f2ec10e98
--- /dev/null
+++ b/priv/repo/migrations/20210426075157_upgrade_oban_jobs_to_v9.exs
@@ -0,0 +1,11 @@
+defmodule Plausible.Repo.Migrations.UpdateObanJobsToV9 do
+ use Ecto.Migration
+
+ def up do
+ Oban.Migrations.up(version: 9)
+ end
+
+ def down do
+ Oban.Migrations.down(version: 9)
+ end
+end
diff --git a/test/workers/check_usage_test.exs b/test/workers/check_usage_test.exs
index 87aa8584d5..48f5124927 100644
--- a/test/workers/check_usage_test.exs
+++ b/test/workers/check_usage_test.exs
@@ -10,7 +10,7 @@ defmodule Plausible.Workers.CheckUsageTest do
@paddle_id_10k Plans.plans()[:monthly][:"10k"][:product_id]
test "ignores user without subscription" do
- CheckUsage.perform(nil, nil)
+ CheckUsage.perform(nil)
assert_no_emails_delivered()
end
@@ -22,7 +22,7 @@ defmodule Plausible.Workers.CheckUsageTest do
last_bill_date: Timex.shift(Timex.today(), days: -1)
)
- CheckUsage.perform(nil, nil)
+ CheckUsage.perform(nil)
assert_no_emails_delivered()
end
@@ -40,7 +40,7 @@ defmodule Plausible.Workers.CheckUsageTest do
last_bill_date: Timex.shift(Timex.today(), days: -1)
)
- CheckUsage.perform(nil, nil, billing_stub)
+ CheckUsage.perform(nil, billing_stub)
assert_no_emails_delivered()
end
@@ -61,7 +61,7 @@ defmodule Plausible.Workers.CheckUsageTest do
last_bill_date: Timex.shift(Timex.today(), days: -1)
)
- CheckUsage.perform(nil, nil, billing_stub)
+ CheckUsage.perform(nil, billing_stub)
assert_email_delivered_with(
to: [user],
@@ -85,7 +85,7 @@ defmodule Plausible.Workers.CheckUsageTest do
last_bill_date: Timex.shift(Timex.today(), days: -1)
)
- CheckUsage.perform(nil, nil, billing_stub)
+ CheckUsage.perform(nil, billing_stub)
assert_email_delivered_with(
to: [user],
@@ -110,7 +110,7 @@ defmodule Plausible.Workers.CheckUsageTest do
last_bill_date: Timex.shift(Timex.today(), days: -1)
)
- CheckUsage.perform(nil, nil, billing_stub)
+ CheckUsage.perform(nil, billing_stub)
assert_email_delivered_with(
to: [user],
@@ -134,7 +134,7 @@ defmodule Plausible.Workers.CheckUsageTest do
last_bill_date: ~D[2021-03-28]
)
- CheckUsage.perform(nil, nil, billing_stub, ~D[2021-03-28])
+ CheckUsage.perform(nil, billing_stub, ~D[2021-03-28])
assert_no_emails_delivered()
end
@@ -156,7 +156,7 @@ defmodule Plausible.Workers.CheckUsageTest do
last_bill_date: Timex.shift(Timex.today(), months: -2, days: -1)
)
- CheckUsage.perform(nil, nil, billing_stub)
+ CheckUsage.perform(nil, billing_stub)
assert_email_delivered_with(
to: [user],
diff --git a/test/workers/clean_email_verification_codes_test.exs b/test/workers/clean_email_verification_codes_test.exs
index ae778065d9..1d764b0673 100644
--- a/test/workers/clean_email_verification_codes_test.exs
+++ b/test/workers/clean_email_verification_codes_test.exs
@@ -18,7 +18,7 @@ defmodule Plausible.Workers.CleanEmailVerificationCodesTest do
issue_code(user, Timex.now() |> Timex.shift(hours: -5))
issue_code(user, Timex.now() |> Timex.shift(days: -5))
- CleanEmailVerificationCodes.perform(nil, nil)
+ CleanEmailVerificationCodes.perform(nil)
refute Repo.exists?(from c in "email_verification_codes", where: c.user_id == ^user.id)
end
@@ -27,7 +27,7 @@ defmodule Plausible.Workers.CleanEmailVerificationCodesTest do
user = insert(:user)
issue_code(user, Timex.now() |> Timex.shift(hours: -2))
- CleanEmailVerificationCodes.perform(nil, nil)
+ CleanEmailVerificationCodes.perform(nil)
assert Repo.exists?(from c in "email_verification_codes", where: c.user_id == ^user.id)
end
diff --git a/test/workers/fetch_tweets_test.exs b/test/workers/fetch_tweets_test.exs
index 7d3c3fb38f..b9112c9519 100644
--- a/test/workers/fetch_tweets_test.exs
+++ b/test/workers/fetch_tweets_test.exs
@@ -5,14 +5,14 @@ defmodule Plausible.Workers.FetchTweetsTest do
test "fetches Twitter referrals from the last day" do
twitter_mock = stub(Plausible.Twitter.Api, :search, fn _link -> [] end)
- FetchTweets.perform(nil, nil, twitter_mock)
+ FetchTweets.perform(nil, twitter_mock)
assert_receive({Plausible.Twitter.Api, :search, ["t.co/a-link"]})
end
test "fetches Twitter referrals from 5-6 days ago" do
twitter_mock = stub(Plausible.Twitter.Api, :search, fn _link -> [] end)
- FetchTweets.perform(nil, nil, twitter_mock)
+ FetchTweets.perform(nil, twitter_mock)
assert_receive({Plausible.Twitter.Api, :search, ["t.co/b-link"]})
end
@@ -39,7 +39,7 @@ defmodule Plausible.Workers.FetchTweetsTest do
_link -> []
end)
- FetchTweets.perform(nil, nil, twitter_mock)
+ FetchTweets.perform(nil, twitter_mock)
[found_tweet] = Repo.all(from(t in Plausible.Twitter.Tweet))
assert found_tweet.tweet_id == "the_tweet_id"
diff --git a/test/workers/notify_annual_renewal_test.exs b/test/workers/notify_annual_renewal_test.exs
index ebb5124d14..5f4b74846b 100644
--- a/test/workers/notify_annual_renewal_test.exs
+++ b/test/workers/notify_annual_renewal_test.exs
@@ -10,7 +10,7 @@ defmodule Plausible.Workers.NotifyAnnualRenewalTest do
@yearly_plan Plans.plans()[:yearly][:"10k"][:product_id]
test "ignores user without subscription" do
- NotifyAnnualRenewal.perform(nil, nil)
+ NotifyAnnualRenewal.perform(nil)
assert_no_emails_delivered()
end
@@ -22,7 +22,7 @@ defmodule Plausible.Workers.NotifyAnnualRenewalTest do
next_bill_date: Timex.shift(Timex.today(), days: 7)
)
- NotifyAnnualRenewal.perform(nil, nil)
+ NotifyAnnualRenewal.perform(nil)
assert_no_emails_delivered()
end
@@ -34,7 +34,7 @@ defmodule Plausible.Workers.NotifyAnnualRenewalTest do
next_bill_date: Timex.shift(Timex.today(), days: 10)
)
- NotifyAnnualRenewal.perform(nil, nil)
+ NotifyAnnualRenewal.perform(nil)
assert_no_emails_delivered()
end
@@ -48,7 +48,7 @@ defmodule Plausible.Workers.NotifyAnnualRenewalTest do
next_bill_date: Timex.shift(Timex.today(), days: 7)
)
- NotifyAnnualRenewal.perform(nil, nil)
+ NotifyAnnualRenewal.perform(nil)
assert_email_delivered_with(
to: [{user.name, user.email}],
@@ -65,7 +65,7 @@ defmodule Plausible.Workers.NotifyAnnualRenewalTest do
next_bill_date: Timex.shift(Timex.today(), days: 2)
)
- NotifyAnnualRenewal.perform(nil, nil)
+ NotifyAnnualRenewal.perform(nil)
assert_email_delivered_with(
to: [{user.name, user.email}],
@@ -80,14 +80,14 @@ defmodule Plausible.Workers.NotifyAnnualRenewalTest do
next_bill_date: Timex.shift(Timex.today(), days: 7)
)
- NotifyAnnualRenewal.perform(nil, nil)
+ NotifyAnnualRenewal.perform(nil)
assert_email_delivered_with(
to: [{user.name, user.email}],
subject: "Your Plausible subscription is up for renewal"
)
- NotifyAnnualRenewal.perform(nil, nil)
+ NotifyAnnualRenewal.perform(nil)
assert_no_emails_delivered()
end
@@ -106,7 +106,7 @@ defmodule Plausible.Workers.NotifyAnnualRenewalTest do
}
])
- NotifyAnnualRenewal.perform(nil, nil)
+ NotifyAnnualRenewal.perform(nil)
assert_email_delivered_with(
to: [{user.name, user.email}],
@@ -123,7 +123,7 @@ defmodule Plausible.Workers.NotifyAnnualRenewalTest do
status: "deleted"
)
- NotifyAnnualRenewal.perform(nil, nil)
+ NotifyAnnualRenewal.perform(nil)
assert_email_delivered_with(
to: [{user.name, user.email}],
diff --git a/test/workers/provision_ssl_certificates_test.exs b/test/workers/provision_ssl_certificates_test.exs
index 0f7661c872..0584f8688c 100644
--- a/test/workers/provision_ssl_certificates_test.exs
+++ b/test/workers/provision_ssl_certificates_test.exs
@@ -11,7 +11,7 @@ defmodule Plausible.Workers.SslCertificatesTest do
stub(SSHEx, :connect, fn _cmd -> {:ok, nil} end)
|> stub(:run, fn _conn, _cmd, _opts -> {:ok, "", 0} end)
- ProvisionSslCertificates.perform(nil, nil, ssh_stub)
+ ProvisionSslCertificates.perform(nil, ssh_stub)
assert_receive(
{SSHEx, :run,
@@ -27,7 +27,7 @@ defmodule Plausible.Workers.SslCertificatesTest do
stub(SSHEx, :connect, fn _cmd -> {:ok, nil} end)
|> stub(:run, fn _conn, _cmd, _opts -> {:ok, "", 0} end)
- ProvisionSslCertificates.perform(nil, nil, ssh_stub)
+ ProvisionSslCertificates.perform(nil, ssh_stub)
domain = Repo.get_by(Plausible.Site.CustomDomain, site_id: site.id)
assert domain.has_ssl_certificate
@@ -41,7 +41,7 @@ defmodule Plausible.Workers.SslCertificatesTest do
stub(SSHEx, :connect, fn _cmd -> {:ok, nil} end)
|> stub(:run, fn _conn, _cmd, _opts -> {:ok, "", 1} end)
- ProvisionSslCertificates.perform(nil, nil, ssh_stub)
+ ProvisionSslCertificates.perform(nil, ssh_stub)
domain = Repo.get_by(Plausible.Site.CustomDomain, site_id: site.id)
refute domain.has_ssl_certificate
diff --git a/test/workers/schedule_email_reports_test.exs b/test/workers/schedule_email_reports_test.exs
index 2554eda6c4..3a05430442 100644
--- a/test/workers/schedule_email_reports_test.exs
+++ b/test/workers/schedule_email_reports_test.exs
@@ -3,17 +3,12 @@ defmodule Plausible.Workers.ScheduleEmailReportsTest do
use Oban.Testing, repo: Plausible.Repo
alias Plausible.Workers.{ScheduleEmailReports, SendEmailReport}
- defp perform(args) do
- ScheduleEmailReports.new(args) |> Oban.insert!()
- Oban.drain_queue(:schedule_email_reports)
- end
-
describe "weekly reports" do
test "schedules weekly report on Monday 9am local timezone" do
site = insert(:site, domain: "test-site.com", timezone: "US/Eastern")
insert(:weekly_report, site: site, recipients: ["[email protected]"])
- perform(%{})
+ perform_job(ScheduleEmailReports, %{})
assert_enqueued(
worker: SendEmailReport,
@@ -26,8 +21,8 @@ defmodule Plausible.Workers.ScheduleEmailReportsTest do
site = insert(:site, domain: "test-site.com", timezone: "US/Eastern")
insert(:weekly_report, site: site, recipients: ["[email protected]"])
- perform(%{})
- perform(%{})
+ perform_job(ScheduleEmailReports, %{})
+ perform_job(ScheduleEmailReports, %{})
assert Enum.count(all_enqueued(worker: SendEmailReport)) == 1
end
@@ -36,10 +31,10 @@ defmodule Plausible.Workers.ScheduleEmailReportsTest do
site = insert(:site, domain: "test-site.com", timezone: "US/Eastern")
insert(:weekly_report, site: site, recipients: ["[email protected]"])
- perform(%{})
+ perform_job(ScheduleEmailReports, %{})
Repo.update_all("oban_jobs", set: [state: "completed"])
assert Enum.empty?(all_enqueued(worker: SendEmailReport))
- perform(%{})
+ perform_job(ScheduleEmailReports, %{})
assert Enum.count(all_enqueued(worker: SendEmailReport)) == 1
end
end
@@ -49,7 +44,7 @@ defmodule Plausible.Workers.ScheduleEmailReportsTest do
site = insert(:site, domain: "test-site.com", timezone: "US/Eastern")
insert(:monthly_report, site: site, recipients: ["[email protected]"])
- perform(%{})
+ perform_job(ScheduleEmailReports, %{})
assert_enqueued(
worker: SendEmailReport,
@@ -62,8 +57,7 @@ defmodule Plausible.Workers.ScheduleEmailReportsTest do
site = insert(:site, domain: "test-site.com", timezone: "US/Eastern")
insert(:monthly_report, site: site, recipients: ["[email protected]"])
- perform(%{})
- perform(%{})
+ perform_job(ScheduleEmailReports, %{})
assert Enum.count(all_enqueued(worker: SendEmailReport)) == 1
end
@@ -72,10 +66,10 @@ defmodule Plausible.Workers.ScheduleEmailReportsTest do
site = insert(:site, domain: "test-site.com", timezone: "US/Eastern")
insert(:monthly_report, site: site, recipients: ["[email protected]"])
- perform(%{})
+ perform_job(ScheduleEmailReports, %{})
Repo.update_all("oban_jobs", set: [state: "completed"])
assert Enum.empty?(all_enqueued(worker: SendEmailReport))
- perform(%{})
+ perform_job(ScheduleEmailReports, %{})
assert Enum.count(all_enqueued(worker: SendEmailReport)) == 1
end
end
diff --git a/test/workers/send_check_stats_emails_test.exs b/test/workers/send_check_stats_emails_test.exs
index 76f763dc5d..9bf1885eb0 100644
--- a/test/workers/send_check_stats_emails_test.exs
+++ b/test/workers/send_check_stats_emails_test.exs
@@ -1,17 +1,14 @@
defmodule Plausible.Workers.SendCheckStatsEmailsTest do
use Plausible.DataCase
+ use Oban.Testing, repo: Plausible.Repo
use Bamboo.Test
-
- defp perform() do
- Plausible.Workers.SendCheckStatsEmails.new(%{}) |> Oban.insert!()
- Oban.drain_queue(:check_stats_emails)
- end
+ alias Plausible.Workers.SendCheckStatsEmails
test "does not send an email before a week has passed" do
user = insert(:user, inserted_at: days_ago(6), last_seen: days_ago(6))
insert(:site, domain: "test-site.com", members: [user])
- perform()
+ perform_job(SendCheckStatsEmails, %{})
assert_no_emails_delivered()
end
@@ -20,7 +17,7 @@ defmodule Plausible.Workers.SendCheckStatsEmailsTest do
user = insert(:user, inserted_at: days_ago(9), last_seen: days_ago(6))
insert(:site, domain: "test-site.com", members: [user])
- perform()
+ perform_job(SendCheckStatsEmails, %{})
assert_no_emails_delivered()
end
@@ -30,7 +27,7 @@ defmodule Plausible.Workers.SendCheckStatsEmailsTest do
site = insert(:site, domain: "test-site.com", members: [user])
insert(:weekly_report, site: site, recipients: ["[email protected]"])
- perform()
+ perform_job(SendCheckStatsEmails, %{})
assert_no_emails_delivered()
end
@@ -39,7 +36,7 @@ defmodule Plausible.Workers.SendCheckStatsEmailsTest do
user = insert(:user, inserted_at: days_ago(8), last_seen: days_ago(8))
insert(:site, domain: "test-site.com", members: [user])
- perform()
+ perform_job(SendCheckStatsEmails, %{})
assert_email_delivered_with(
to: [{user.name, user.email}],
diff --git a/test/workers/send_email_report_test.exs b/test/workers/send_email_report_test.exs
index 6d13b82a0a..09f45e33e9 100644
--- a/test/workers/send_email_report_test.exs
+++ b/test/workers/send_email_report_test.exs
@@ -2,20 +2,16 @@ defmodule Plausible.Workers.SendEmailReportTest do
import Plausible.TestUtils
use Plausible.DataCase
use Bamboo.Test
+ use Oban.Testing, repo: Plausible.Repo
alias Plausible.Workers.SendEmailReport
alias Timex.Timezone
- defp perform(args) do
- SendEmailReport.new(args) |> Oban.insert!()
- Oban.drain_queue(:send_email_reports)
- end
-
describe "weekly reports" do
test "sends weekly report to all recipients" do
site = insert(:site, domain: "test-site.com", timezone: "US/Eastern")
insert(:weekly_report, site: site, recipients: ["[email protected]", "[email protected]"])
- perform(%{"site_id" => site.id, "interval" => "weekly"})
+ perform_job(SendEmailReport, %{"site_id" => site.id, "interval" => "weekly"})
assert_email_delivered_with(
subject: "Weekly report for #{site.domain}",
@@ -53,7 +49,7 @@ defmodule Plausible.Workers.SendEmailReportTest do
%{domain: site.domain, timestamp: Timezone.convert(this_monday, "UTC")}
])
- perform(%{"site_id" => site.id, "interval" => "weekly"})
+ perform_job(SendEmailReport, %{"site_id" => site.id, "interval" => "weekly"})
assert_delivered_email_matches(%{
to: [nil: "[email protected]"],
@@ -77,7 +73,7 @@ defmodule Plausible.Workers.SendEmailReportTest do
|> Timex.beginning_of_month()
|> Timex.format!("{Mfull}")
- perform(%{"site_id" => site.id, "interval" => "monthly"})
+ perform_job(SendEmailReport, %{"site_id" => site.id, "interval" => "monthly"})
assert_email_delivered_with(
subject: "#{last_month} report for #{site.domain}",
diff --git a/test/workers/send_site_setup_emails_test.exs b/test/workers/send_site_setup_emails_test.exs
index cdbadd613c..76cc6ead05 100644
--- a/test/workers/send_site_setup_emails_test.exs
+++ b/test/workers/send_site_setup_emails_test.exs
@@ -1,20 +1,16 @@
defmodule Plausible.Workers.SendSiteSetupEmailsTest do
use Plausible.DataCase
use Bamboo.Test
+ use Oban.Testing, repo: Plausible.Repo
import Plausible.TestUtils
alias Plausible.Workers.SendSiteSetupEmails
- defp perform() do
- SendSiteSetupEmails.new(%{}) |> Oban.insert!()
- Oban.drain_queue(:site_setup_emails)
- end
-
describe "when user has not managed to set up the site" do
test "does not send an email 47 hours after site creation" do
user = insert(:user)
insert(:site, members: [user], inserted_at: hours_ago(47))
- perform()
+ perform_job(SendSiteSetupEmails, %{})
assert_no_emails_delivered()
end
@@ -23,7 +19,7 @@ defmodule Plausible.Workers.SendSiteSetupEmailsTest do
user = insert(:user)
insert(:site, members: [user], inserted_at: hours_ago(49))
- perform()
+ perform_job(SendSiteSetupEmails, %{})
assert_email_delivered_with(
to: [{user.name, user.email}],
@@ -35,7 +31,7 @@ defmodule Plausible.Workers.SendSiteSetupEmailsTest do
user = insert(:user)
insert(:site, members: [user], inserted_at: hours_ago(73))
- perform()
+ perform_job(SendSiteSetupEmails, %{})
assert_no_emails_delivered()
end
@@ -46,7 +42,7 @@ defmodule Plausible.Workers.SendSiteSetupEmailsTest do
user = insert(:user)
insert(:site, members: [user], domain: "test-site.com")
- perform()
+ perform_job(SendSiteSetupEmails, %{})
assert_email_delivered_with(
to: [{user.name, user.email}],
@@ -58,7 +54,7 @@ defmodule Plausible.Workers.SendSiteSetupEmailsTest do
user = insert(:user)
site = insert(:site, members: [user], inserted_at: hours_ago(49))
- perform()
+ perform_job(SendSiteSetupEmails, %{})
assert_email_delivered_with(
to: [{user.name, user.email}],
@@ -66,7 +62,7 @@ defmodule Plausible.Workers.SendSiteSetupEmailsTest do
)
create_pageviews([%{domain: site.domain}])
- perform()
+ perform_job(SendSiteSetupEmails, %{})
assert_email_delivered_with(
to: [{user.name, user.email}],
@@ -79,7 +75,7 @@ defmodule Plausible.Workers.SendSiteSetupEmailsTest do
test "does not send an email before 48h have passed" do
insert(:user, inserted_at: hours_ago(47))
- perform()
+ perform_job(SendSiteSetupEmails, %{})
assert_no_emails_delivered()
end
@@ -87,7 +83,7 @@ defmodule Plausible.Workers.SendSiteSetupEmailsTest do
test "sends the create site email after 48h" do
user = insert(:user, inserted_at: hours_ago(49))
- perform()
+ perform_job(SendSiteSetupEmails, %{})
assert_email_delivered_with(
to: [{user.name, user.email}],
diff --git a/test/workers/send_trial_notifications_test.exs b/test/workers/send_trial_notifications_test.exs
index 5035487ee7..501fc44770 100644
--- a/test/workers/send_trial_notifications_test.exs
+++ b/test/workers/send_trial_notifications_test.exs
@@ -1,11 +1,8 @@
defmodule Plausible.Workers.SendTrialNotificationsTest do
use Plausible.DataCase
use Bamboo.Test
-
- defp perform() do
- Plausible.Workers.SendTrialNotifications.new(%{}) |> Oban.insert!()
- Oban.drain_queue(:trial_notification_emails)
- end
+ use Oban.Testing, repo: Plausible.Repo
+ alias Plausible.Workers.SendTrialNotifications
test "does not send a notification if user didn't set up their site" do
insert(:user, inserted_at: Timex.now() |> Timex.shift(days: -14))
@@ -13,7 +10,7 @@ defmodule Plausible.Workers.SendTrialNotificationsTest do
insert(:user, inserted_at: Timex.now() |> Timex.shift(days: -30))
insert(:user, inserted_at: Timex.now() |> Timex.shift(days: -31))
- perform()
+ perform_job(SendTrialNotifications, %{})
assert_no_emails_delivered()
end
@@ -23,7 +20,7 @@ defmodule Plausible.Workers.SendTrialNotificationsTest do
user = insert(:user, trial_expiry_date: Timex.now() |> Timex.shift(days: 7))
insert(:site, domain: "test-site.com", members: [user])
- perform()
+ perform_job(SendTrialNotifications, %{})
assert_delivered_email(PlausibleWeb.Email.trial_one_week_reminder(user))
end
@@ -32,7 +29,7 @@ defmodule Plausible.Workers.SendTrialNotificationsTest do
user = insert(:user, trial_expiry_date: Timex.now() |> Timex.shift(days: 1))
insert(:site, domain: "test-site.com", members: [user])
- perform()
+ perform_job(SendTrialNotifications, %{})
assert_delivered_email(PlausibleWeb.Email.trial_upgrade_email(user, "tomorrow", {3, 0}))
end
@@ -41,7 +38,7 @@ defmodule Plausible.Workers.SendTrialNotificationsTest do
user = insert(:user, trial_expiry_date: Timex.today())
insert(:site, domain: "test-site.com", members: [user])
- perform()
+ perform_job(SendTrialNotifications, %{})
assert_delivered_email(PlausibleWeb.Email.trial_upgrade_email(user, "today", {3, 0}))
end
@@ -68,7 +65,7 @@ defmodule Plausible.Workers.SendTrialNotificationsTest do
user = insert(:user, trial_expiry_date: Timex.today() |> Timex.shift(days: -1))
insert(:site, domain: "test-site.com", members: [user])
- perform()
+ perform_job(SendTrialNotifications, %{})
assert_delivered_email(PlausibleWeb.Email.trial_over_email(user))
end
@@ -78,7 +75,7 @@ defmodule Plausible.Workers.SendTrialNotificationsTest do
insert(:site, domain: "test-site.com", members: [user])
insert(:subscription, user: user)
- perform()
+ perform_job(SendTrialNotifications, %{})
assert_no_emails_delivered()
end
diff --git a/test/workers/spike_notifier_test.exs b/test/workers/spike_notifier_test.exs
index d0fd500a2f..4deb9b2952 100644
--- a/test/workers/spike_notifier_test.exs
+++ b/test/workers/spike_notifier_test.exs
@@ -17,7 +17,7 @@ defmodule Plausible.Workers.SpikeNotifierTest do
stub(Plausible.Stats.Clickhouse, :current_visitors, fn _site, _query -> 5 end)
|> stub(:top_sources, fn _site, _query, _limit, _page, _show_noref -> [] end)
- SpikeNotifier.perform(nil, nil, clickhouse_stub)
+ SpikeNotifier.perform(nil, clickhouse_stub)
assert_no_emails_delivered()
end
@@ -35,7 +35,7 @@ defmodule Plausible.Workers.SpikeNotifierTest do
stub(Plausible.Stats.Clickhouse, :current_visitors, fn _site, _query -> 10 end)
|> stub(:top_sources, fn _site, _query, _limit, _page, _show_noref -> [] end)
- SpikeNotifier.perform(nil, nil, clickhouse_stub)
+ SpikeNotifier.perform(nil, clickhouse_stub)
assert_email_delivered_with(
subject: "Traffic spike on #{site.domain}",
@@ -56,14 +56,14 @@ defmodule Plausible.Workers.SpikeNotifierTest do
stub(Plausible.Stats.Clickhouse, :current_visitors, fn _site, _query -> 10 end)
|> stub(:top_sources, fn _site, _query, _limit, _page, _show_noref -> [] end)
- SpikeNotifier.perform(nil, nil, clickhouse_stub)
+ SpikeNotifier.perform(nil, clickhouse_stub)
assert_email_delivered_with(
subject: "Traffic spike on #{site.domain}",
to: [nil: "[email protected]"]
)
- SpikeNotifier.perform(nil, nil, clickhouse_stub)
+ SpikeNotifier.perform(nil, clickhouse_stub)
assert_no_emails_delivered()
end