Skip to content

Commit

Permalink
add files
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Dec 24, 2020
1 parent 8dc4425 commit 33f5ac6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
30 changes: 15 additions & 15 deletions src/Illuminate/Bus/DatabaseBatchRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Illuminate\Database\Query\Expression;
use Illuminate\Support\Str;

class DatabaseBatchRepository implements BatchRepository, Prunable
class DatabaseBatchRepository implements PrunableBatchRepository
{
/**
* The batch factory instance.
Expand Down Expand Up @@ -231,23 +231,10 @@ public function delete(string $batchId)
$this->connection->table($this->table)->where('id', $batchId)->delete();
}

/**
* Execute the given Closure within a storage specific transaction.
*
* @param \Closure $callback
* @return mixed
*/
public function transaction(Closure $callback)
{
return $this->connection->transaction(function () use ($callback) {
return $callback();
});
}

/**
* Prune all of the entries older than the given date.
*
* @param DateTimeInterface $before
* @param \DateTimeInterface $before
* @return int
*/
public function prune(DateTimeInterface $before)
Expand All @@ -267,6 +254,19 @@ public function prune(DateTimeInterface $before)
return $totalDeleted;
}

/**
* Execute the given Closure within a storage specific transaction.
*
* @param \Closure $callback
* @return mixed
*/
public function transaction(Closure $callback)
{
return $this->connection->transaction(function () use ($callback) {
return $callback();
});
}

/**
* Convert the given raw batch to a Batch object.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

use DateTimeInterface;

interface Prunable
interface PrunableBatchRepository extends BatchRepository
{
/**
* Prune all of the entries older than the given date.
*
* @param DateTimeInterface $before
* @param \DateTimeInterface $before
* @return int
*/
public function prune(DateTimeInterface $before);
Expand Down
6 changes: 1 addition & 5 deletions src/Illuminate/Queue/Console/PruneBatchesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ public function handle()
$repository = $this->laravel[BatchRepository::class];

if ($repository instanceof Prunable) {
$hours = $this->option('hours');

$before = Carbon::now()->subHours($hours);

$count = $repository->prune($before);
$count = $repository->prune(Carbon::now()->subHours($this->option('hours')));
}

$this->info("{$count} entries deleted!");
Expand Down

0 comments on commit 33f5ac6

Please sign in to comment.