Refactor a little bit
authorMaxim Filippov <colixer@gmail.com>
Fri, 1 Mar 2019 18:17:20 +0000 (21:17 +0300)
committerMaxim Filippov <colixer@gmail.com>
Fri, 1 Mar 2019 18:17:23 +0000 (21:17 +0300)
lib/pleroma/user.ex
lib/pleroma/web/admin_api/admin_api_controller.ex

index 37f8da8922f800cd014eafd58b14c770407d620d..3c6fb4f9b614f46ed9f9a225527bc64ad9322e89 100644 (file)
@@ -763,17 +763,13 @@ defmodule Pleroma.User 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 @@ defmodule Pleroma.User 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
index 270097d3564a504070a87d3d1aadff6abb3105d3..33f9689cd3a9df76819ce9027e7c38450a883faa 100644 (file)
@@ -70,11 +70,11 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController 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 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
 
     conn
     |> json(
-      AccountView.render("index.json", %{
+      AccountView.render("index.json",
         users: users,
         count: length(users),
         page_size: @users_page_size
-      })
+      )
     )
   end