Remove old Plausible.Site.Membership references (#4921)

* remove old membership refs

* remove unused functions
This commit is contained in:
ruslandoga 2024-12-18 16:14:52 +07:00 committed by GitHub
parent 0db7176726
commit 6c24bd2075
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 37 deletions

View File

@ -32,8 +32,10 @@ defmodule Plausible.Site.Memberships.AcceptInvitation do
| Ecto.Changeset.t() | Ecto.Changeset.t()
| :no_plan | :no_plan
@type membership :: %Plausible.Teams.Membership{}
@spec bulk_transfer_ownership_direct([Site.t()], Auth.User.t()) :: @spec bulk_transfer_ownership_direct([Site.t()], Auth.User.t()) ::
{:ok, [Site.Membership.t()]} | {:error, transfer_error()} {:ok, [membership]} | {:error, transfer_error()}
def bulk_transfer_ownership_direct(sites, new_owner) do def bulk_transfer_ownership_direct(sites, new_owner) do
Repo.transaction(fn -> Repo.transaction(fn ->
for site <- sites do for site <- sites do

View File

@ -346,40 +346,4 @@ defmodule Plausible.Sites do
select: s select: s
) )
end end
def owned_sites_locked?(user) do
user
|> owned_sites_query()
|> where([s], s.locked == true)
|> Repo.exists?()
end
def owned_sites_count(user) do
user
|> owned_sites_query()
|> Repo.aggregate(:count)
end
def owned_sites_domains(user) do
user
|> owned_sites_query()
|> select([site], site.domain)
|> Repo.all()
end
def owned_site_ids(user) do
user
|> owned_sites_query()
|> select([site], site.id)
|> Repo.all()
end
defp owned_sites_query(user) do
from(s in Site,
join: sm in Site.Membership,
on: sm.site_id == s.id,
where: sm.role == :owner,
where: sm.user_id == ^user.id
)
end
end end