akkoma/test/mix/tasks/pleroma
ilja eb503f093c Prune Objects --keep-threads
This adds an option to the prune_objects mix task.
The original way deleted all non-local public posts older than a certain time frame.
Here we add a different query which you can call using the option --keep-threads.

We query from the activities table all context id's where
    1. the newest activity with this context is still old
    2. none of the activities with this context is is local
    3. none of the activities with this context is bookmarked
and delete all objects with these contexts.

The idea is that posts with local activities (posts, replies, likes, repeats...) may be intersesting to keep.
Besides that, a post lives in a certain context (the thread), so we keep the whole thread as well.

Caveats:
* Quotes have a different context. Therefore, when someone quotes a post, it's possible the quoted post will still be deleted.
* Although undocumented (in docs/docs/administration/CLI_tasks/database.md/#prune-old-remote-posts-from-the-database), the 'normal' delete action still keeps old remote non-public posts. With this option we don't care about scope.
* I ran this on my instance, but directly on the DB. I still need to test to be sure that we don't get a time-out error or something.

Some statistics from explain analyse:
(cost=1402845.92..1933782.00 rows=3810907 width=62) (actual time=2562455.486..2562455.495 rows=0 loops=1)
 Planning Time: 505.327 ms
 Trigger for constraint chat_message_references_object_id_fkey: time=651939.797 calls=921740
 Trigger for constraint deliveries_object_id_fkey: time=52036.009 calls=921740
 Trigger for constraint hashtags_objects_object_id_fkey: time=20665.778 calls=921740
 Execution Time: 3287933.902 ms
2023-01-04 19:17:03 +01:00
..
ecto Upgrade Ecto to v3.6.2, remove deprecated ecto_explain 2021-06-23 13:22:32 -05:00
app_test.exs Bump Copyright to 2021 2021-01-13 07:49:50 +01:00
config_test.exs Remove quack, ensure adapter is finch 2022-12-11 23:22:35 +00:00
count_statuses_test.exs Bump Copyright to 2021 2021-01-13 07:49:50 +01:00
database_test.exs Prune Objects --keep-threads 2023-01-04 19:17:03 +01:00
digest_test.exs Fix digest test 2022-06-29 20:45:05 +01:00
ecto_test.exs Bump Copyright to 2021 2021-01-13 07:49:50 +01:00
email_test.exs Merge branch 'develop' into refactor/deactivated_user_field 2021-01-18 14:58:21 -06:00
emoji_test.exs Bump Copyright to 2021 2021-01-13 07:49:50 +01:00
frontend_test.exs Bump Copyright to 2021 2021-01-13 07:49:50 +01:00
instance_test.exs Bump Copyright to 2021 2021-01-13 07:49:50 +01:00
refresh_counter_cache_test.exs Bump Copyright to 2021 2021-01-13 07:49:50 +01:00
relay_test.exs Don't persist local undone follow (#194) 2022-08-31 18:00:36 +00:00
robots_txt_test.exs Convert tests to all use clear_config instead of Pleroma.Config.put 2021-01-26 11:58:43 -06:00
uploads_test.exs Bump Copyright to 2021 2021-01-13 07:49:50 +01:00
user_test.exs Ensure consistent behavior between pleroma.user activate/deactivate mix tasks 2021-01-25 10:48:28 -06:00