forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
144 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,8 +82,6 @@ public function setRequest(Request $request) | |
{ | ||
$this->request = $request; | ||
|
||
$this->user = null; | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Illuminate\Bus; | ||
|
||
use DateTimeInterface; | ||
|
||
interface PrunableBatchRepository extends BatchRepository | ||
{ | ||
/** | ||
* Prune all of the entries older than the given date. | ||
* | ||
* @param \DateTimeInterface $before | ||
* @return int | ||
*/ | ||
public function prune(DateTimeInterface $before); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Illuminate\Queue\Console; | ||
|
||
use Carbon\Carbon; | ||
use Illuminate\Bus\BatchRepository; | ||
use Illuminate\Bus\Prunable; | ||
use Illuminate\Console\Command; | ||
|
||
class PruneBatchesCommand extends Command | ||
{ | ||
/** | ||
* The console command signature. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'queue:prune-batches {--hours=24 : The number of hours to retain batch data}'; | ||
|
||
/** | ||
* The name of the console command. | ||
* | ||
* This name is used to identify the command during lazy loading. | ||
* | ||
* @var string|null | ||
*/ | ||
protected static $defaultName = 'queue:prune-batches'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Prune stale entries from the batches database'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return void | ||
*/ | ||
public function handle() | ||
{ | ||
$count = 0; | ||
|
||
$repository = $this->laravel[BatchRepository::class]; | ||
|
||
if ($repository instanceof Prunable) { | ||
$count = $repository->prune(Carbon::now()->subHours($this->option('hours'))); | ||
} | ||
|
||
$this->info("{$count} entries deleted!"); | ||
} | ||
} |