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
Fix check_usage
Uku Taht7fe50c3ef29c
diff --git a/lib/plausible/billing/plans.ex b/lib/plausible/billing/plans.exindex 743ac9be4f..e3650e111a 100644--- a/lib/plausible/billing/plans.ex+++ b/lib/plausible/billing/plans.ex@@ -74,8 +74,11 @@ defmodule Plausible.Billing.Plans doenddef allowance(subscription) do- Enum.find(@all_plans, fn plan -> plan[:product_id] == subscription.paddle_plan_id end)- |> Map.fetch!(:limit)+ found = Enum.find(@all_plans, fn plan -> plan[:product_id] == subscription.paddle_plan_id end)++ if found do+ Map.fetch!(found, :limit)+ endenddefp number_format(num) dodiff --git a/lib/workers/check_usage.ex b/lib/workers/check_usage.exindex 5b7b0ca165..37206b46a0 100644--- a/lib/workers/check_usage.ex+++ b/lib/workers/check_usage.ex@@ -39,6 +39,7 @@ defmodule Plausible.Workers.CheckUsage dojoin: s in Plausible.Billing.Subscription,on: s.user_id == u.id,where: s.status == "active",+ where: not is_nil(s.last_bill_date),# Accounts for situations like last_bill_date==2021-01-31 AND today==2021-03-01. Since February never reaches the 31st day, the account is checked on 2021-03-01.where:least(day_of_month(s.last_bill_date), day_of_month(last_day_of_month(^yesterday))) ==