From d537bfd4e1e3119188519a4b1839fdbe3f6fad39 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Wed, 9 Oct 2019 13:11:57 +0700 Subject: Add a task to re-count statuses for all users --- lib/mix/tasks/pleroma/count_statuses.ex | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 lib/mix/tasks/pleroma/count_statuses.ex (limited to 'lib/mix/tasks') diff --git a/lib/mix/tasks/pleroma/count_statuses.ex b/lib/mix/tasks/pleroma/count_statuses.ex new file mode 100644 index 000000000..e1e8195dd --- /dev/null +++ b/lib/mix/tasks/pleroma/count_statuses.ex @@ -0,0 +1,22 @@ +defmodule Mix.Tasks.Pleroma.CountStatuses do + @shortdoc "Re-counts statuses for all users" + + use Mix.Task + alias Pleroma.User + import Ecto.Query + + def run([]) do + Mix.Pleroma.start_pleroma() + + stream = + User + |> where(local: true) + |> Pleroma.Repo.stream() + + Pleroma.Repo.transaction(fn -> + Enum.each(stream, &User.update_note_count/1) + end) + + Mix.Pleroma.shell_info("Done") + end +end -- cgit v1.2.3