Skip to content

Commit 1a43141

Browse files
author
Lasse Lehtinen
committed
Added --exclude-filter
1 parent b717b5b commit 1a43141

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/Commands/BatchRetryCommand.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class BatchRetryCommand extends Command
1919
{--limit= : Limit the amount of jobs to retry}
2020
{--queue= : Only retry on a specific queue}
2121
{--filter= : Filter by a specific string. This will be a search in the payload of the job}
22+
{--exclude-filter= : Filter by excluding a specific string. This will be a search in the payload of the job}
2223
{--filter-by-exception= : Filter by a specific string on the exception.}
2324
{--dry-run : Do a dry run of the batch retry to have an idea of the size of the batch}';
2425

@@ -57,6 +58,9 @@ public function handle()
5758
->when($this->option('filter'), function ($query) {
5859
$query->where('payload', 'like', '%'.$this->option('filter').'%');
5960
})
61+
->when($this->option('exclude-filter'), function ($query) {
62+
$query->where('payload', 'not like', '%'.$this->option('exclude-filter').'%');
63+
})
6064
->when($this->option('filter-by-exception'), function ($query) {
6165
$query->where('exception', 'like', '%'.$this->option('filter-by-exception').'%');
6266
});

tests/BatchRetryCommandTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,25 @@ public function it_can_batch_retry_using_search()
9090
$this->assertNotNull($someOtherFailedJob->fresh());
9191
}
9292

93+
/** @test */
94+
public function it_can_batch_retry_using_excluded_search()
95+
{
96+
$someFailedJob = factory(FailedJob::class)->create([
97+
'payload' => ['displayName' => 'App\Jobs\SomeJob']
98+
]);
99+
$someOtherFailedJob = factory(FailedJob::class)->create([
100+
'payload' => ['displayName' => 'App\Jobs\SomeOtherJob']
101+
]);
102+
103+
Artisan::call('queue:failed:batch-retry', [
104+
'--exclude-filter' => 'SomeJob',
105+
]);
106+
107+
$this->assertEquals(1, DB::table('jobs')->count());
108+
$this->assertNotNull($someFailedJob->fresh());
109+
$this->assertNull($someOtherFailedJob->fresh());
110+
}
111+
93112
/** @test */
94113
public function it_can_batch_retry_limiting_by_date()
95114
{

0 commit comments

Comments
 (0)