Skip to content

Commit

Permalink
remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertJoonas committed Jul 1, 2024
1 parent ad9af81 commit 6dde8f2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 53 deletions.
18 changes: 1 addition & 17 deletions lib/plausible/billing/plans.ex
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
defmodule Plausible.Billing.Plans do
alias Plausible.Billing.Subscriptions
use Plausible.Repo
alias Plausible.Billing.{Quota, Subscription, Plan, EnterprisePlan}
alias Plausible.Billing.Feature.{StatsAPI, Props}
alias Plausible.Billing.{Subscription, Plan, EnterprisePlan}
alias Plausible.Auth.User

for f <- [
Expand Down Expand Up @@ -235,21 +234,6 @@ defmodule Plausible.Billing.Plans do
Enum.find(available_plans, &(usage_during_cycle < &1.monthly_pageview_limit))
end

def suggest_tier(user) do
growth_features =
if Timex.before?(user.inserted_at, @business_tier_launch) do
[StatsAPI, Props]
else
[]
end

if Enum.any?(Quota.Usage.features_usage(user), &(&1 not in growth_features)) do
:business
else
:growth
end
end

def all() do
@legacy_plans ++ @plans_v1 ++ @plans_v2 ++ @plans_v3 ++ @plans_v4 ++ sandbox_plans()
end
Expand Down
6 changes: 3 additions & 3 deletions lib/plausible_web/live/choose_plan.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ defmodule PlausibleWeb.Live.ChoosePlan do
Plans.available_plans_for(user, with_prices: true, customer_ip: remote_ip)
end)
|> assign_new(:recommended_tier, fn %{usage: usage, available_plans: available_plans} ->
highest_growth_plan = List.last(available_plans.growth)
highest_business_plan = List.last(available_plans.business)
Quota.suggest_tier(usage, highest_growth_plan, highest_business_plan)
highest_growth_plan = List.last(available_plans.growth)
highest_business_plan = List.last(available_plans.business)
Quota.suggest_tier(usage, highest_growth_plan, highest_business_plan)
end)
|> assign_new(:available_volumes, fn %{available_plans: available_plans} ->
get_available_volumes(available_plans)
Expand Down
33 changes: 0 additions & 33 deletions test/plausible/billing/plans_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -284,39 +284,6 @@ defmodule Plausible.Billing.PlansTest do
end
end

describe "suggest_tier/1" do
test "suggests Business when user has used a premium feature" do
user = insert(:user)
insert(:api_key, user: user)

assert Plans.suggest_tier(user) == :business
end

test "suggests Growth when no premium features used" do
user = insert(:user)
site = insert(:site, members: [user])
insert(:goal, site: site, event_name: "goals_is_not_premium")

assert Plans.suggest_tier(user) == :growth
end

test "suggests Growth tier for a user who used the Stats API, but signed up before it was considered a premium feature" do
user = insert(:user, inserted_at: ~N[2023-10-25 10:00:00])
insert(:api_key, user: user)

assert Plans.suggest_tier(user) == :growth
end

@tag :ee_only
test "suggests Business tier for a user who used the Revenue Goals, even when they signed up before Business tier release" do
user = insert(:user, inserted_at: ~N[2023-10-25 10:00:00])
site = insert(:site, members: [user])
insert(:goal, site: site, currency: :USD, event_name: "Purchase")

assert Plans.suggest_tier(user) == :business
end
end

defp assert_generation(plans_list, generation) do
assert List.first(plans_list).generation == generation
end
Expand Down

0 comments on commit 6dde8f2

Please sign in to comment.