- def maybe_local_user_query(query, local) do
- if local, do: local_user_query(query), else: query
- end
-
- def local_user_query(query \\ User) do
- from(
- u in query,
- where: u.local == true,
- where: not is_nil(u.nickname)
- )
- end
-
- def maybe_external_user_query(query, external) do
- if external, do: external_user_query(query), else: query
- end
-
- def external_user_query(query \\ User) do
- from(
- u in query,
- where: u.local == false,
- where: not is_nil(u.nickname)
- )
- end
-
- def maybe_active_user_query(query, active) do
- if active, do: active_user_query(query), else: query
- end
-
- def active_user_query(query \\ User) do
- from(
- u in query,
- where: fragment("not (?->'deactivated' @> 'true')", u.info),
- where: not is_nil(u.nickname)
- )
- end
-
- def maybe_deactivated_user_query(query, deactivated) do
- if deactivated, do: deactivated_user_query(query), else: query
- end
-
- def deactivated_user_query(query \\ User) do
- from(
- u in query,
- where: fragment("(?->'deactivated' @> 'true')", u.info),
- where: not is_nil(u.nickname)
- )
- end
-
- def active_local_user_query do
- from(
- u in local_user_query(),
- where: fragment("not (?->'deactivated' @> 'true')", u.info)
- )
- end
-
- def moderator_user_query do
- from(
- u in User,
- where: u.local == true,
- where: fragment("?->'is_moderator' @> 'true'", u.info)
- )
- end
-
-