diff options
author | lain <lain@soykaf.club> | 2019-10-09 14:11:23 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2019-10-09 14:11:23 +0000 |
commit | f64dfd317f256aff4b039d9da944414880f2f7b0 (patch) | |
tree | 502ffacd137f111c45a0c6110a21bc9e2275d749 /lib/mix/tasks | |
parent | 6355694309b0bad3687a8a7820b81ebf6625751d (diff) | |
parent | d537bfd4e1e3119188519a4b1839fdbe3f6fad39 (diff) | |
download | pleroma-f64dfd317f256aff4b039d9da944414880f2f7b0.tar.gz |
Merge branch 'feature/count-statuses-task' into 'develop'
Add a task to re-count statuses for all users
Closes #1305
See merge request pleroma/pleroma!1823
Diffstat (limited to 'lib/mix/tasks')
-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 |