logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

search.ex (758B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 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. @spec user(map()) :: {:ok, [User.t()], pos_integer()}
  10. def user(params \\ %{}) do
  11. query =
  12. params
  13. |> Map.drop([:page, :page_size])
  14. |> Map.put(:invisible, false)
  15. |> User.Query.build()
  16. |> order_by(desc: :id)
  17. paginated_query =
  18. User.Query.paginate(query, params[:page] || 1, params[:page_size] || @page_size)
  19. count = Repo.aggregate(query, :count, :id)
  20. results = Repo.all(paginated_query)
  21. {:ok, results, count}
  22. end
  23. end