From f635b675b2cc0bc10b395cd71ae1720b0696d364 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Fri, 1 Mar 2019 21:17:20 +0300 Subject: [PATCH] Refactor a little bit --- lib/pleroma/user.ex | 16 ++++------------ .../web/admin_api/admin_api_controller.ex | 8 ++++---- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 37f8da892..3c6fb4f9b 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -763,17 +763,13 @@ def search(term, options \\ %{}) do if options[:resolve], do: get_or_fetch(term) fts_results = - do_search(fts_search_subquery(term, query), options[:for_user], %{ - limit: options[:limit] - }) + do_search(fts_search_subquery(term, query), options[:for_user], limit: options[:limit]) {:ok, trigram_results} = Repo.transaction(fn -> Ecto.Adapters.SQL.query(Repo, "select set_limit(0.25)", []) - do_search(trigram_search_subquery(term, query), options[:for_user], %{ - limit: options[:limit] - }) + do_search(trigram_search_subquery(term, query), options[:for_user], limit: options[:limit]) end) Enum.uniq_by(fts_results ++ trigram_results, & &1.id) @@ -1024,12 +1020,8 @@ def unblock_domain(user, domain) do update_and_set_cache(cng) end - def maybe_local_user_query(local) when local == true do - local_user_query() - end - - def maybe_local_user_query(local) when local == false do - User + def maybe_local_user_query(local) do + if local, do: local_user_query(), else: User end def local_user_query do diff --git a/lib/pleroma/web/admin_api/admin_api_controller.ex b/lib/pleroma/web/admin_api/admin_api_controller.ex index 270097d35..33f9689cd 100644 --- a/lib/pleroma/web/admin_api/admin_api_controller.ex +++ b/lib/pleroma/web/admin_api/admin_api_controller.ex @@ -70,11 +70,11 @@ def list_users(%{assigns: %{user: admin}} = conn, %{"page" => page_string}) do do: conn |> json( - AccountView.render("index.json", %{ + AccountView.render("index.json", users: users, count: count, page_size: @users_page_size - }) + ) ) end @@ -89,11 +89,11 @@ def search_users(%{assigns: %{user: admin}} = conn, %{"query" => term} = params) conn |> json( - AccountView.render("index.json", %{ + AccountView.render("index.json", users: users, count: length(users), page_size: @users_page_size - }) + ) ) end