forked from mirror/pixelfed
Add CatchUnoptimizedMedia cronjob command
This commit is contained in:
parent
1b145ab4ea
commit
8de99876e8
2 changed files with 49 additions and 2 deletions
47
app/Console/Commands/CatchUnoptimizedMedia.php
Normal file
47
app/Console/Commands/CatchUnoptimizedMedia.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Media;
|
||||
use App\Jobs\ImageOptimizePipeline\ImageOptimize;
|
||||
|
||||
class CatchUnoptimizedMedia extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'media:optimize';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Find and optimize media that has not yet been optimized.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Media $media)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$medias = Media::whereNull('processed_at')->take(50)->get();
|
||||
foreach($medias as $media) {
|
||||
ImageOptimize::dispatch($media);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,8 +24,8 @@ class Kernel extends ConsoleKernel
|
|||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
// $schedule->command('inspire')
|
||||
// ->hourly();
|
||||
$schedule->command('media:optimize')
|
||||
->hourly();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue