Prune Objects --keep-threads option #350
No reviewers
Labels
No labels
approved, awaiting change
bug
configuration
documentation
duplicate
enhancement
extremely low priority
feature request
Fix it yourself
help wanted
invalid
mastodon_api
needs docs
needs tests
not a bug
planned
pleroma_api
privacy
question
static_fe
triage
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: AkkomaGang/akkoma#350
Loading…
Reference in a new issue
No description provided.
Delete branch "ilja/akkoma:prune_objects_whithout_breaking_threads"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 interesting 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.fixed in #379Note that this removes from the objects table, but not from the activities.See #427 for that.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
TODO
We keep it as currently implemented and just don't care about scope with this optionWe add logic to not delete non-public posts either (I'll have to see how costly that becomes)hm, decent point
i might err on giving quotes the same context?
though that might then cause them to be caught by context fetching
bf60996c6d
to9ba6d1bb08
WIP: [I have questions] Prune Objects --keep-threads optionto Prune Objects --keep-threads option9ba6d1bb08
tof1739ac17b
that's quite the query you've got going there, splitting into 2PRs was probably the right move
this one looks fine though! thanks a lot~