From bfde0fdea67c8c4203cb95ddfa767c0652bdbcd0 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 24 Nov 2018 14:03:15 -0700 Subject: [PATCH] Fix thumbnail regression --- app/Console/Commands/UpdateCommand.php | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/app/Console/Commands/UpdateCommand.php b/app/Console/Commands/UpdateCommand.php index d39d89e2..84877d0a 100644 --- a/app/Console/Commands/UpdateCommand.php +++ b/app/Console/Commands/UpdateCommand.php @@ -33,6 +33,7 @@ class UpdateCommand extends Command '0.1.7', '0.1.8', '0.1.9', + '0.2.1', ]; protected $version; @@ -76,10 +77,15 @@ class UpdateCommand extends Command case '0.1.8': $this->info('You are running an older version that doesn\'t require any updates!'); break; + case '0.1.9': $this->update019(); break; + case '0.2.1': + $this->update021(); + break; + default: # code... break; @@ -127,6 +133,34 @@ class UpdateCommand extends Command $bar->finish(); } + public function update021() + { + $this->buildVersionFile(); + $v = $this->getVersionFile(); + if($v['updated'] == true) { + $this->info('Already up to date!'); + exit; + } + + $statusCount = Status::count(); + $this->info('Running updates ...'); + $bar = $this->output->createProgressBar($statusCount); + Status::has('media')->chunk(200, function($statuses) use ($bar) { + + foreach($statuses as $status) { + if($status->firstMedia()) { + $media = $status->firstMedia(); + if(in_array($media->mime, ['image/jpeg', 'image/png'])) { + ImageThumbnail::dispatch($media); + } + } + $bar->advance(); + } + }); + $this->updateVersionFile('0.2.1', true); + $bar->finish(); + } + protected function buildVersionFile() { $path = storage_path('app/version.json');