Fix sites query invitation left join lookup (#3480)

This commit is contained in:
hq1 2023-11-02 15:01:29 +01:00 committed by GitHub
parent 30b4dc2872
commit 6e6508a359
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,7 +20,9 @@ defmodule Plausible.Sites do
from(s in Plausible.Site,
left_join: sm in assoc(s, :memberships),
left_join: i in assoc(s, :invitations),
where: sm.user_id == ^user.id or i.email == ^user.email,
where:
(is_nil(i.id) and sm.user_id == ^user.id) or
(not is_nil(i.id) and i.email == ^user.email),
select: %{
s
| list_type: