mirror of
https://github.com/plausible/analytics.git
synced 2024-11-24 04:32:57 +03:00
Add subscription info to admin panel
This commit is contained in:
parent
e692afc20e
commit
a5135d34fa
@ -1,6 +1,10 @@
|
||||
defmodule Plausible.Auth.UserAdmin do
|
||||
use Plausible.Repo
|
||||
|
||||
def custom_index_query(_conn, _schema, query) do
|
||||
from(r in query, preload: [:subscription])
|
||||
end
|
||||
|
||||
def form_fields(_) do
|
||||
[
|
||||
name: nil,
|
||||
@ -13,10 +17,32 @@ defmodule Plausible.Auth.UserAdmin do
|
||||
[
|
||||
name: nil,
|
||||
email: nil,
|
||||
email_verified: nil,
|
||||
trial_expiry_date: nil,
|
||||
inserted_at: nil,
|
||||
last_seen: nil
|
||||
subscription_tier: %{value: &subscription_tier/1},
|
||||
subscription_status: %{value: &subscription_status/1}
|
||||
]
|
||||
end
|
||||
|
||||
defp subscription_tier(user) do
|
||||
if user.subscription && user.subscription.status == "active" do
|
||||
quota = PlausibleWeb.AuthView.subscription_quota(user.subscription)
|
||||
interval = PlausibleWeb.AuthView.subscription_interval(user.subscription)
|
||||
"#{quota} (#{interval})"
|
||||
else
|
||||
"--"
|
||||
end
|
||||
end
|
||||
|
||||
defp subscription_status(user) do
|
||||
cond do
|
||||
user.subscription ->
|
||||
PlausibleWeb.AuthView.present_subscription_status(user.subscription.status)
|
||||
|
||||
Plausible.Billing.on_trial?(user) ->
|
||||
"On trial"
|
||||
|
||||
true ->
|
||||
"Trial expired"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user