make search provider configurable
[akkoma] / lib / mix / tasks / pleroma / search.ex
index 4acd0e34ac7fcf4e7cc74c3e1b745fbe4ea11eb0..9e0f376c38957a2c3042fb15b45196b9edabb07e 100644 (file)
@@ -6,32 +6,33 @@ defmodule Mix.Tasks.Pleroma.Search do
   use Mix.Task
   import Mix.Pleroma
   import Ecto.Query
-  alias Pleroma.Elasticsearch
   alias Pleroma.Activity
-  alias Pleroma.Repo
   alias Pleroma.Pagination
 
   @shortdoc "Manages elasticsearch"
 
-  def run(["import" | rest]) do
+  def run(["import" | _rest]) do
     start_pleroma()
 
-    query = from(a in Activity, where: not ilike(a.actor, "%/relay"))
-    |> Activity.with_preloaded_object
-    |> Activity.with_preloaded_user_actor
+    from(a in Activity, where: not ilike(a.actor, "%/relay"))
+    |> Activity.with_preloaded_object()
+    |> Activity.with_preloaded_user_actor()
     |> get_all
   end
 
   defp get_all(query, max_id \\ nil) do
     params = %{limit: 20}
-    params = if max_id == nil do
+
+    params =
+      if max_id == nil do
         params
-    else
+      else
         Map.put(params, :max_id, max_id)
-    end
+      end
 
-    res = query
-    |> Pagination.fetch_paginated(params)
+    res =
+      query
+      |> Pagination.fetch_paginated(params)
 
     if res == [] do
       :ok
@@ -42,5 +43,4 @@ defmodule Mix.Tasks.Pleroma.Search do
       get_all(query, List.last(res).id)
     end
   end
-
 end