Skip to content

Commit

Permalink
Remove old Plausible.Site.Membership references (#4921)
Browse files Browse the repository at this point in the history
* remove old membership refs

* remove unused functions
  • Loading branch information
ruslandoga authored Dec 18, 2024
1 parent 0db7176 commit 6c24bd2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 37 deletions.
4 changes: 3 additions & 1 deletion lib/plausible/site/memberships/accept_invitation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ defmodule Plausible.Site.Memberships.AcceptInvitation do
| Ecto.Changeset.t()
| :no_plan

@type membership :: %Plausible.Teams.Membership{}

@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
Repo.transaction(fn ->
for site <- sites do
Expand Down
36 changes: 0 additions & 36 deletions lib/plausible/sites.ex
Original file line number Diff line number Diff line change
Expand Up @@ -346,40 +346,4 @@ defmodule Plausible.Sites do
select: s
)
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

0 comments on commit 6c24bd2

Please sign in to comment.