Skip to content
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

[7.x] Added range option to queue:retry command #33627

Merged
merged 2 commits into from
Jul 23, 2020
Merged

[7.x] Added range option to queue:retry command #33627

merged 2 commits into from
Jul 23, 2020

Conversation

eusonlito
Copy link
Contributor

@eusonlito eusonlito commented Jul 23, 2020

Sometimes we need to send to queue retry several jobs and artisan queue:retry onyl allow a list of plain ids.

With this PR this command could accept a range of ids to retry on queue on new option --range=*.

This new option only allow integers as value:

$ php artisan queue:retry all
array:4 [
  0 => 50
  1 => 49
  2 => 48
  3 => 47
]
$ php artisan queue:retry 1
array:1 [
  0 => "1"
]
$ php artisan queue:retry 1 2
array:2 [
  0 => "1"
  1 => "2"
]
$ php artisan queue:retry a-a
array:1 [
  0 => "a-a"
]
$ php artisan queue:retry --range 10-20
array:11 [
  0 => 10
  1 => 11
  2 => 12
  3 => 13
  4 => 14
  5 => 15
  6 => 16
  7 => 17
  8 => 18
  9 => 19
  10 => 20
]
$ php artisan queue:retry 1 2 --range 10-20
array:13 [
  0 => "1"
  1 => "2"
  2 => 10
  3 => 11
  4 => 12
  5 => 13
  6 => 14
  7 => 15
  8 => 16
  9 => 17
  10 => 18
  11 => 19
  12 => 20
]
$ php artisan queue:retry 1 2 --range 10-15 --range 20-25
array:14 [
  0 => "1"
  1 => "2"
  2 => 10
  3 => 11
  4 => 12
  5 => 13
  6 => 14
  7 => 15
  8 => 20
  9 => 21
  10 => 22
  11 => 23
  12 => 24
  13 => 25
]
$ php artisan queue:retry 1 2 3 4 --range=10-10
array:5 [
  0 => "1"
  1 => "2"
  2 => "3"
  3 => "4"
  4 => 10
]
$ php artisan queue:retry 1 2 --range 15-10
array:8 [
  0 => "1"
  1 => "2"
  2 => 15
  3 => 14
  4 => 13
  5 => 12
  6 => 11
  7 => 10
]

This PR is compatible with current command options and don't break with custom IDs.

@francoism90
Copy link

Many thanks, I was waiting for this one. :)

@foremtehan
Copy link
Contributor

foremtehan commented Aug 3, 2020

It would be nice if we could do this in running jobs too. (queue:work --range=1-20)

@nandi95
Copy link
Contributor

nandi95 commented Nov 3, 2022

I'm confused. This is a really nice (undocumented) feature but, the logic finds records by the uuid column not the id.

$job = $this->laravel['queue.failer']->find($id);

I could go ahead and add some tests to confirm what I'm saying if we think this might be the case.
@taylorotwell @eusonlito

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants