aboutsummaryrefslogtreecommitdiff
path: root/lib/mix/tasks
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2019-10-09 14:11:23 +0000
committerlain <lain@soykaf.club>2019-10-09 14:11:23 +0000
commitf64dfd317f256aff4b039d9da944414880f2f7b0 (patch)
tree502ffacd137f111c45a0c6110a21bc9e2275d749 /lib/mix/tasks
parent6355694309b0bad3687a8a7820b81ebf6625751d (diff)
parentd537bfd4e1e3119188519a4b1839fdbe3f6fad39 (diff)
downloadpleroma-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.ex22
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