-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[8.x] Add command to clean batches table #35694
Conversation
I'm not sure if "flush-batch" is the right word? That makes me think all of the table's records will be deleted when really it's just pruning existing ones. |
@taylorotwell I agree, As I mentioned in the OP |
I would likely call it something like |
Pushed change to |
/** | ||
* Prune all of the entries older than the given date. | ||
* | ||
* @param DateTimeInterface $before |
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.
Missing slash
/** | ||
* Prune all of the entries older than the given date. | ||
* | ||
* @param DateTimeInterface $before |
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.
Missing slash
$totalDeleted = 0; | ||
|
||
do { | ||
$deleted = $query->take(1000)->delete(); |
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.
Why don't you just use the query builder's each function?
Provides a
queue:prune-batches
command for cleaning thejob_batches
table added in 8.x.Heavily inspired by the
telescope:prune
command this change is almost an exact copy of that.https://github.com/laravel/telescope/blob/master/src/Console/PruneCommand.php
It has an
--hours
optional argument that defaults to24
and it uses thefinished_at
column to do the date comparison.Similarly to telescope it can easily be put into the scheduler:
None of the queue commands currently have tests so I haven't added any for this one.
If you want me to add tests please do let me know.