Reuse query from User.restrict_deactivated/1

This commit is contained in:
Egor Kislitsyn 2019-05-14 18:29:10 +07:00
parent 5e2b491276
commit b92c004ea8
2 changed files with 2 additions and 4 deletions

View file

@ -115,7 +115,7 @@ def user_info(%User{} = user) do
}
end
defp restrict_deactivated(query) do
def restrict_deactivated(query) do
from(u in query,
where: not fragment("? \\? 'deactivated' AND ?->'deactivated' @> 'true'", u.info, u.info)
)

View file

@ -119,9 +119,7 @@ defp compose_query({:active, _}, query) do
end
defp compose_query({:deactivated, false}, query) do
from(u in query,
where: not fragment("? \\? 'deactivated' AND ?->'deactivated' @> 'true'", u.info, u.info)
)
User.restrict_deactivated(query)
end
defp compose_query({:deactivated, true}, query) do