Enum.uniq_by(fts_results ++ trigram_results, & &1.id)
end
- def all_except_one(user, page, page_size) do
+ def all(page, page_size) do
from(
u in User,
- where: u.id != ^user.id,
limit: ^page_size,
offset: ^((page - 1) * page_size),
order_by: u.id
def list_users(%{assigns: %{user: admin}} = conn, %{"page" => page_string}) do
with {page, _} <- Integer.parse(page_string),
- users <- User.all_except_one(admin, page, @users_page_size),
+ users <- User.all(page, @users_page_size),
count <- User.count_all_except_one(admin),
do:
conn
"count" => 1,
"page_size" => 50,
"users" => [
+ %{
+ "deactivated" => admin.info.deactivated,
+ "id" => admin.id,
+ "nickname" => admin.nickname
+ },
%{
"deactivated" => user.info.deactivated,
"id" => user.id,
|> get("/api/pleroma/admin/users/search?query=bo")
assert json_response(conn, 200) == %{
- "count" => 1,
- "page_size" => 50,
- "users" => [
- %{
- "deactivated" => user.info.deactivated,
- "id" => user.id,
- "nickname" => user.nickname
- }
- ]
- }
+ "count" => 1,
+ "page_size" => 50,
+ "users" => [
+ %{
+ "deactivated" => user.info.deactivated,
+ "id" => user.id,
+ "nickname" => user.nickname
+ }
+ ]
+ }
end
test "only local users" do
|> get("/api/pleroma/admin/users/search?query=bo&local=true")
assert json_response(conn, 200) == %{
- "count" => 1,
- "page_size" => 50,
- "users" => [
- %{
- "deactivated" => user.info.deactivated,
- "id" => user.id,
- "nickname" => user.nickname
- }
- ]
- }
+ "count" => 1,
+ "page_size" => 50,
+ "users" => [
+ %{
+ "deactivated" => user.info.deactivated,
+ "id" => user.id,
+ "nickname" => user.nickname
+ }
+ ]
+ }
end
end
end