Add a task to re-count statuses for all users
This commit is contained in:
parent
6355694309
commit
d537bfd4e1
3 changed files with 62 additions and 0 deletions
22
lib/mix/tasks/pleroma/count_statuses.ex
Normal file
22
lib/mix/tasks/pleroma/count_statuses.ex
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue