mirror of
https://github.com/plausible/analytics.git
synced 2025-01-03 15:17:58 +03:00
Remove old Plausible.Site.Membership
references (#4921)
* remove old membership refs * remove unused functions
This commit is contained in:
parent
0db7176726
commit
6c24bd2075
@ -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
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user