From 9d5d964bf87dd153b5f10ad3bb02a7a76459f577 Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Tue, 14 Dec 2021 14:28:15 +0000 Subject: [PATCH] merge --- lib/mix/tasks/pleroma/activity.ex | 1 - lib/mix/tasks/pleroma/search.ex | 4 +- lib/pleroma/elasticsearch/store.ex | 52 +++++++++++-------- .../search/elasticsearch/hashtag_parser.ex | 2 +- .../search/elasticsearch/user_paser.ex | 2 +- 5 files changed, 33 insertions(+), 28 deletions(-) diff --git a/lib/mix/tasks/pleroma/activity.ex b/lib/mix/tasks/pleroma/activity.ex index ca9224b67..3a79d8f20 100644 --- a/lib/mix/tasks/pleroma/activity.ex +++ b/lib/mix/tasks/pleroma/activity.ex @@ -4,7 +4,6 @@ defmodule Mix.Tasks.Pleroma.Activity do alias Pleroma.Activity - alias Pleroma.Activity.Search alias Pleroma.User alias Pleroma.Web.CommonAPI alias Pleroma.Pagination diff --git a/lib/mix/tasks/pleroma/search.ex b/lib/mix/tasks/pleroma/search.ex index 2324561c1..1fd880eab 100644 --- a/lib/mix/tasks/pleroma/search.ex +++ b/lib/mix/tasks/pleroma/search.ex @@ -24,8 +24,8 @@ def run(["import", "activities" | _rest]) do end def run(["import", "users" | _rest]) do - start_pleroma() - + start_pleroma() + from(u in User, where: u.nickname not in ["internal.fetch", "relay"]) |> get_all(:users) end diff --git a/lib/pleroma/elasticsearch/store.ex b/lib/pleroma/elasticsearch/store.ex index 2d8aeabc2..2f8375c48 100644 --- a/lib/pleroma/elasticsearch/store.ex +++ b/lib/pleroma/elasticsearch/store.ex @@ -46,26 +46,31 @@ def maybe_put_into_elasticsearch(_) do end def put(%Activity{} = activity) do - {:ok, _} = Elastix.Document.index( - url(), - "activities", - "activity", - DocumentMappings.Activity.id(activity), - DocumentMappings.Activity.encode(activity) - ) - {:ok, _} = bulk_post( - activity.object.hashtags, :hashtags - ) + {:ok, _} = + Elastix.Document.index( + url(), + "activities", + "activity", + DocumentMappings.Activity.id(activity), + DocumentMappings.Activity.encode(activity) + ) + + {:ok, _} = + bulk_post( + activity.object.hashtags, + :hashtags + ) end def put(%User{} = user) do - {:ok, _ } = Elastix.Document.index( - url(), - "users", - "user", - DocumentMappings.User.id(user), - DocumentMappings.User.encode(user) - ) + {:ok, _} = + Elastix.Document.index( + url(), + "users", + "user", + DocumentMappings.User.id(user), + DocumentMappings.User.encode(user) + ) end def bulk_post(data, :activities) do @@ -87,12 +92,13 @@ def bulk_post(data, :activities) do end) |> List.flatten() - {:ok, %{body: %{"errors" => false}}} = Elastix.Bulk.post( - url(), - d, - index: "activities", - type: "activity" - ) + {:ok, %{body: %{"errors" => false}}} = + Elastix.Bulk.post( + url(), + d, + index: "activities", + type: "activity" + ) end def bulk_post(data, :users) do diff --git a/lib/pleroma/search/elasticsearch/hashtag_parser.ex b/lib/pleroma/search/elasticsearch/hashtag_parser.ex index 6e2801ed0..644969c78 100644 --- a/lib/pleroma/search/elasticsearch/hashtag_parser.ex +++ b/lib/pleroma/search/elasticsearch/hashtag_parser.ex @@ -3,7 +3,7 @@ defp to_es(term) when is_binary(term) do %{ term: %{ hashtag: %{ - value: String.downcase(term), + value: String.downcase(term) } } } diff --git a/lib/pleroma/search/elasticsearch/user_paser.ex b/lib/pleroma/search/elasticsearch/user_paser.ex index 96bfdc7d2..76da3bd33 100644 --- a/lib/pleroma/search/elasticsearch/user_paser.ex +++ b/lib/pleroma/search/elasticsearch/user_paser.ex @@ -25,7 +25,7 @@ defp to_es(term) when is_binary(term) do query: term, operator: "AND" } - } + } } ] }