From bcdbc1715ee39aea5f53956c862c572b4ed2bf03 Mon Sep 17 00:00:00 2001 From: Deon George Date: Mon, 16 Dec 2019 20:37:48 +1100 Subject: [PATCH] Update VideoScanAll --- app/Console/Commands/PhotoScanAll.php | 2 +- app/Console/Commands/VideoScanAll.php | 86 ++++++++++++++------------- 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/app/Console/Commands/PhotoScanAll.php b/app/Console/Commands/PhotoScanAll.php index eb3ce23..ea6d1e1 100644 --- a/app/Console/Commands/PhotoScanAll.php +++ b/app/Console/Commands/PhotoScanAll.php @@ -26,7 +26,7 @@ class PhotoScanAll extends Command * * @var string */ - protected $description = 'Rescan Photos'; + protected $description = 'Scan Photos'; /** * Create a new command instance. diff --git a/app/Console/Commands/VideoScanAll.php b/app/Console/Commands/VideoScanAll.php index ad63063..9098d75 100644 --- a/app/Console/Commands/VideoScanAll.php +++ b/app/Console/Commands/VideoScanAll.php @@ -4,55 +4,59 @@ namespace App\Console\Commands; use Illuminate\Console\Command; use Illuminate\Foundation\Bus\DispatchesJobs; -use Log; -use App\Model\Video; +use Illuminate\Support\Facades\Log; + +use App\Models\Video; use App\Jobs\CatalogScan; class VideoScanAll extends Command { use DispatchesJobs; - /** - * The name and signature of the console command. - * - * @var string - */ - protected $signature = 'video:scanall'; + /** + * The name and signature of the console command. + * + * @var string + */ + protected $signature = 'video:scanall'. + '{--scanned : Rescan Scanned Videos}'; - /** - * The console command description. - * - * @var string - */ - protected $description = 'Command description'; + /** + * The console command description. + * + * @var string + */ + protected $description = 'Scan Videos'; - /** - * Create a new command instance. - * - * @return void - */ - public function __construct() - { - parent::__construct(); - } + /** + * Create a new command instance. + * + * @return void + */ + public function __construct() + { + parent::__construct(); + } - /** - * Execute the console command. - * - * @return mixed - */ - public function handle() - { - Video::NotScanned()->chunk(200,function ($data) { - foreach ($data as $o) - { - if ($o->remove) { - Log::warning(sprintf('Not scanning [%s], marked for removal',$o->id)); - continue; + /** + * Execute the console command. + * + * @return mixed + */ + public function handle() + { + $o = ($this->option('scanned') ? Video::NotRemove() : Video::NotScanned()); + + $o->each(function ($item) { + if ($item->remove) { + Log::warning(sprintf('Not scanning [%s], marked for removal',$item->id)); + return; } - $this->dispatch((new CatalogScan($o))->onQueue('scan')); - } - }); - } -} + Log::info(sprintf('%s: Rescanning [%s]',__METHOD__,$item->id)); + $this->dispatch((new CatalogScan($item))->onQueue('scan')); + }); + + Log::info(sprintf('Processed [%s]',$o->count())); + } +} \ No newline at end of file