logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

count_statuses.ex (584B)


  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. defmodule Mix.Tasks.Pleroma.CountStatuses do
  5. @shortdoc "Re-counts statuses for all users"
  6. use Mix.Task
  7. alias Pleroma.User
  8. import Ecto.Query
  9. def run([]) do
  10. Mix.Pleroma.start_pleroma()
  11. stream =
  12. User
  13. |> where(local: true)
  14. |> Pleroma.Repo.stream()
  15. Pleroma.Repo.transaction(fn ->
  16. Enum.each(stream, &User.update_note_count/1)
  17. end)
  18. Mix.Pleroma.shell_info("Done")
  19. end
  20. end