diff options
author | Egor Kislitsyn <egor@kislitsyn.com> | 2019-10-09 13:11:57 +0700 |
---|---|---|
committer | Egor Kislitsyn <egor@kislitsyn.com> | 2019-10-09 13:11:57 +0700 |
commit | d537bfd4e1e3119188519a4b1839fdbe3f6fad39 (patch) | |
tree | 502ffacd137f111c45a0c6110a21bc9e2275d749 /lib | |
parent | 6355694309b0bad3687a8a7820b81ebf6625751d (diff) | |
download | pleroma-d537bfd4e1e3119188519a4b1839fdbe3f6fad39.tar.gz |
Add a task to re-count statuses for all users
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mix/tasks/pleroma/count_statuses.ex | 22 |
1 files changed, 22 insertions, 0 deletions
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 |