Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jun 16, 2021
1 parent 26fc7e9 commit 7aca658
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ protected function registerQueuePruneBatchesCommand()
protected function registerQueuePruneFailedJobsCommand()
{
$this->app->singleton('command.queue.prune-failed-jobs', function () {
return new PruneFailedJobsCommand();
return new PruneFailedJobsCommand;
});
}

Expand Down
6 changes: 5 additions & 1 deletion src/Illuminate/Queue/Console/PruneFailedJobsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PruneFailedJobsCommand extends Command
/**
* Execute the console command.
*
* @return void
* @return int|null
*/
public function handle()
{
Expand All @@ -36,6 +36,10 @@ public function handle()

if ($failer instanceof PrunableFailedJobProvider) {
$count = $failer->prune(Carbon::now()->subHours($this->option('hours')));
} else {
$this->error('The ['.class_basename($failer).'] failed job storage driver does not support pruning.');

return 1;
}

$this->info("{$count} entries deleted!");
Expand Down
23 changes: 11 additions & 12 deletions src/Illuminate/Queue/Failed/DatabaseFailedJobProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,6 @@ public function flush()
$this->getTable()->delete();
}

/**
* Get a new query builder instance for the table.
*
* @return \Illuminate\Database\Query\Builder
*/
protected function getTable()
{
return $this->resolver->connection($this->database)->table($this->table);
}

/**
* Prune all of the entries older than the given date.
*
Expand All @@ -124,8 +114,7 @@ protected function getTable()
*/
public function prune(DateTimeInterface $before)
{
$query = $this->getTable()
->where('failed_at', '<', $before);
$query = $this->getTable()->where('failed_at', '<', $before);

$totalDeleted = 0;

Expand All @@ -137,4 +126,14 @@ public function prune(DateTimeInterface $before)

return $totalDeleted;
}

/**
* Get a new query builder instance for the table.
*
* @return \Illuminate\Database\Query\Builder
*/
protected function getTable()
{
return $this->resolver->connection($this->database)->table($this->table);
}
}
23 changes: 11 additions & 12 deletions src/Illuminate/Queue/Failed/DatabaseUuidFailedJobProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,6 @@ public function flush()
$this->getTable()->delete();
}

/**
* Get a new query builder instance for the table.
*
* @return \Illuminate\Database\Query\Builder
*/
protected function getTable()
{
return $this->resolver->connection($this->database)->table($this->table);
}

/**
* Prune all of the entries older than the given date.
*
Expand All @@ -137,8 +127,7 @@ protected function getTable()
*/
public function prune(DateTimeInterface $before)
{
$query = $this->getTable()
->where('failed_at', '<', $before);
$query = $this->getTable()->where('failed_at', '<', $before);

$totalDeleted = 0;

Expand All @@ -150,4 +139,14 @@ public function prune(DateTimeInterface $before)

return $totalDeleted;
}

/**
* Get a new query builder instance for the table.
*
* @return \Illuminate\Database\Query\Builder
*/
protected function getTable()
{
return $this->resolver->connection($this->database)->table($this->table);
}
}

0 comments on commit 7aca658

Please sign in to comment.