move to 2.5.5
[anni] / lib / mix / tasks / pleroma / count_statuses.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Mix.Tasks.Pleroma.CountStatuses do
6   @shortdoc "Re-counts statuses for all users"
7
8   use Mix.Task
9   alias Pleroma.User
10   import Ecto.Query
11
12   def run([]) do
13     Mix.Pleroma.start_pleroma()
14
15     stream =
16       User
17       |> where(local: true)
18       |> Pleroma.Repo.stream()
19
20     Pleroma.Repo.transaction(fn ->
21       Enum.each(stream, &User.update_note_count/1)
22     end)
23
24     Mix.Pleroma.shell_info("Done")
25   end
26 end