New: add filters to widen action schedulers cleanup#24
Conversation
|
@edjeavons What do you think about reducing the clean up schedule to 2 weeks by default? |
|
Two weeks is sufficient. I can't think of any examples when we've needed to look back any further, and if something ever comes up we do have backups that we can restore in an emergency. It would be ideal if we could vary the retention period (e.g. delete completed jobs after a week but keep cancelled & failed job for a month) but WooCommerce core doesn't offer that. |
edjeavons
left a comment
There was a problem hiding this comment.
All good to merge if you're happy with my commits.
I merged the latest main branch changes into this one so it could be tested on that basis before completing PR. That led to a few more lib files being added that aren't really relevant but will be added sooner or later anyway.
Added filters for:
action_scheduler_retention_period(the period actions need to be older than in order to be deleted), set this toWEEK_IN_SECONDS * 4as a default but can be overridden withorbit_action_scheduler_retention_periodaction_scheduler_default_cleaner_statusesset this to[ 'complete', 'canceled', 'failed' ]as default and can be overridden withorbit_action_scheduler_default_cleaner_statusesaction_scheduler_cleanup_batch_sizeset this to be1000as default and can be overridden withorbit_action_scheduler_cleanup_batch_sizeSomething we need to review is the retention period, we discussed doing one month (which is actually the Action Scheduler default) but its not cleaning enough actions for what we were hoping to see, there just seems to be a lot of actions from woocommerce and its plugins e.g.
MailChimp_WooCommerce_Single_Orderhas a lot of actions on itThis can vary depending on how busy the site is, so maybe we need to keep the 1 month default and review on a case by case basis the larger sites and consider reducing it for ones that still have a lot in their log.