Add a message with a count of posts to index
authorEkaterina Vaartis <vaartis@kotobank.ch>
Mon, 23 Aug 2021 17:02:34 +0000 (20:02 +0300)
committerFloatingGhost <hannah@coffee-and-dreams.uk>
Wed, 29 Jun 2022 19:48:29 +0000 (20:48 +0100)
lib/mix/tasks/pleroma/search/meilisearch.ex

index 230be5aa127809c6bbe69b9d6d5206e814d7851b..557b0618212fd7cb5c8c1049e9ab3ce714205ad8 100644 (file)
@@ -38,7 +38,7 @@ defmodule Mix.Tasks.Pleroma.Search.Meilisearch do
 
     Pleroma.Repo.transaction(
       fn ->
-        Pleroma.Repo.stream(
+        query =
           from(Pleroma.Object,
             # Only index public posts which are notes and have some text
             where:
@@ -46,7 +46,13 @@ defmodule Mix.Tasks.Pleroma.Search.Meilisearch do
                 fragment("LENGTH(data->>'content') > 0") and
                 fragment("data->'to' \\? ?", ^Pleroma.Constants.as_public()),
             order_by: [desc: fragment("data->'published'")]
-          ),
+          )
+
+        count = query |> Pleroma.Repo.aggregate(:count, :data)
+        IO.puts("Entries to index: #{count}")
+
+        Pleroma.Repo.stream(
+          query,
           timeout: :infinity
         )
         |> Stream.map(&Pleroma.Search.Meilisearch.object_to_search_data/1)