Add a task to re-count statuses for all users
[akkoma] / lib / mix / tasks / pleroma / count_statuses.ex
1 defmodule Mix.Tasks.Pleroma.CountStatuses do
2 @shortdoc "Re-counts statuses for all users"
3
4 use Mix.Task
5 alias Pleroma.User
6 import Ecto.Query
7
8 def run([]) do
9 Mix.Pleroma.start_pleroma()
10
11 stream =
12 User
13 |> where(local: true)
14 |> Pleroma.Repo.stream()
15
16 Pleroma.Repo.transaction(fn ->
17 Enum.each(stream, &User.update_note_count/1)
18 end)
19
20 Mix.Pleroma.shell_info("Done")
21 end
22 end