-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a data retention cron #42
base: master
Are you sure you want to change the base?
Conversation
These weren't being cleaned up anywhere else.
|
||
// Ensure they haven't provided a negative interval as this will cause the | ||
// threshold to move forward in time. | ||
if ($job_spec['min_age']->invert) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of complaining, could we just toggle-off the invert
flag?
@@ -59,6 +59,20 @@ | |||
Register::cronJob('daily', 'Sprout\\Controllers\\Admin\\FileAdminController', 'cronCleanupInvalid'); | |||
Register::cronJob('daily', 'Sprout\\Controllers\\ContentSubscribeController', 'cronSendSubscriptions'); | |||
Register::cronJob('daily', 'Sprout\\Controllers\\Admin\\ActionLogAdminController', 'cronCleanup'); | |||
Register::cronJob('daily', 'Sprout\\Controllers\\RetentionCronController', 'cronRetention'); | |||
|
|||
// Purge exception log entries after 14 days |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These comments don't really add anything here, except maybe the fact that ISO 8601 period specs are a little opaque.
Of course we could switch away from ISO 8601 period specs and instead to strtotime
relative time strings (e.g. '14 days'
)
|
||
$threshold = clone $now; | ||
$threshold->sub($job_spec['min_age']); | ||
$threshold = $threshold->format('Y-m-d H:i:s'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the comparison be made on the date portion only?
Cron::message("Purging records from '{$job_spec['table']}' ({$job_spec['column']}) updated before {$threshold}"); | ||
|
||
$conds = [ | ||
[$job_spec['column'], '<', $threshold] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is an index on the column, will it be hit?
|
||
$q = "DELETE FROM ~{$job_spec['table']} WHERE {$where}"; | ||
$count = Pdb::q($q, $params, 'count'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we run OPTIMIZE TABLE
on MyISAM tables (either automatically or when set via an option flag)?
This provides a simple, data driven interface to purging old data from tables.
I've moved exception log and worker job clean-up into retention jobs, which in the former case avoids a potentially lengthy operation (delete on MyIASM tables grows increasingly slow the more operations performed sans
OPTIMIZE TABLE
) occurring during a request.Added new jobs for
rate_limit_hits
andlogin_attempts
because we weren't cleaning these up.