Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

37 строки
884B

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.AdminAPI.Search do
  5. import Ecto.Query
  6. alias Pleroma.Repo
  7. alias Pleroma.User
  8. @page_size 50
  9. defmacro not_empty_string(string) do
  10. quote do
  11. is_binary(unquote(string)) and unquote(string) != ""
  12. end
  13. end
  14. @spec user(map()) :: {:ok, [User.t()], pos_integer()}
  15. def user(params \\ %{}) do
  16. query =
  17. params
  18. |> Map.drop([:page, :page_size])
  19. |> Map.put(:invisible, false)
  20. |> User.Query.build()
  21. |> order_by(desc: :id)
  22. paginated_query =
  23. User.Query.paginate(query, params[:page] || 1, params[:page_size] || @page_size)
  24. count = Repo.aggregate(query, :count, :id)
  25. results = Repo.all(paginated_query)
  26. {:ok, results, count}
  27. end
  28. end