2020-10-12 19:00:50 +02:00
|
|
|
# Pleroma: A lightweight social networking server
|
2021-01-13 07:49:20 +01:00
|
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
2020-10-12 19:00:50 +02:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2019-10-09 08:11:57 +02:00
|
|
|
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
|