Log number of deleted rows in prune_orphaned_activities
This gives feedback when to stop rerunning limited batches. Most of the diff is just adjusting indentation; best reviewed with whitespace-only changes hidden, e.g. `git diff -w`.
This commit is contained in:
parent
fa52093bac
commit
e64f031167
2 changed files with 44 additions and 33 deletions
|
@ -59,6 +59,11 @@ This will prune activities which are no longer referenced by anything.
|
||||||
Such activities might be the result of running `prune_objects` without `--prune-orphaned-activities`.
|
Such activities might be the result of running `prune_objects` without `--prune-orphaned-activities`.
|
||||||
The same notes and warnings apply as for `prune_objects`.
|
The same notes and warnings apply as for `prune_objects`.
|
||||||
|
|
||||||
|
The task will print out how many rows were freed in total in its last
|
||||||
|
line of output in the form `Deleted 345 rows`.
|
||||||
|
When running the job in limited batches this can be used to determine
|
||||||
|
when all orphaned activities have been deleted.
|
||||||
|
|
||||||
=== "OTP"
|
=== "OTP"
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|
|
@ -29,6 +29,7 @@ defmodule Mix.Tasks.Pleroma.Database do
|
||||||
end
|
end
|
||||||
|
|
||||||
# Prune activities who link to a single object
|
# Prune activities who link to a single object
|
||||||
|
{:ok, %{:num_rows => del_single}} =
|
||||||
"""
|
"""
|
||||||
delete from public.activities
|
delete from public.activities
|
||||||
where id in (
|
where id in (
|
||||||
|
@ -47,6 +48,7 @@ defmodule Mix.Tasks.Pleroma.Database do
|
||||||
|> Repo.query([], timeout: :infinity)
|
|> Repo.query([], timeout: :infinity)
|
||||||
|
|
||||||
# Prune activities who link to an array of objects
|
# Prune activities who link to an array of objects
|
||||||
|
{:ok, %{:num_rows => del_array}} =
|
||||||
"""
|
"""
|
||||||
delete from public.activities
|
delete from public.activities
|
||||||
where id in (
|
where id in (
|
||||||
|
@ -63,6 +65,8 @@ defmodule Mix.Tasks.Pleroma.Database do
|
||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
|> Repo.query([], timeout: :infinity)
|
|> Repo.query([], timeout: :infinity)
|
||||||
|
|
||||||
|
del_single + del_array
|
||||||
end
|
end
|
||||||
|
|
||||||
def run(["remove_embedded_objects" | args]) do
|
def run(["remove_embedded_objects" | args]) do
|
||||||
|
@ -131,7 +135,9 @@ defmodule Mix.Tasks.Pleroma.Database do
|
||||||
|
|
||||||
Logger.info(log_message)
|
Logger.info(log_message)
|
||||||
|
|
||||||
prune_orphaned_activities(limit)
|
deleted = prune_orphaned_activities(limit)
|
||||||
|
|
||||||
|
Logger.info("Deleted #{deleted} rows")
|
||||||
end
|
end
|
||||||
|
|
||||||
def run(["prune_objects" | args]) do
|
def run(["prune_objects" | args]) do
|
||||||
|
|
Loading…
Reference in a new issue