info(' ____ _ ______ __ '); $this->info(' / __ \(_) _____ / / __/__ ____/ / '); $this->info(' / /_/ / / |/_/ _ \/ / /_/ _ \/ __ / '); $this->info(' / ____/ /> info(' /_/ /_/_/|_|\___/_/_/ \___/\__,_/ '); $this->info(' '); $this->info(' '); $this->info('Pixelfed version: ' . config('pixelfed.version')); $this->info(' '); $this->info('Running Fix Hashtags command'); $this->info(' '); $missingCount = StatusHashtag::doesntHave('profile')->doesntHave('status')->count(); if($missingCount > 0) { $this->info("Found {$missingCount} orphaned StatusHashtag records to delete ..."); $this->info(' '); $bar = $this->output->createProgressBar($missingCount); $bar->start(); foreach(StatusHashtag::doesntHave('profile')->doesntHave('status')->get() as $tag) { $tag->delete(); $bar->advance(); } $bar->finish(); $this->info(' '); } else { $this->info(' '); $this->info('Found no orphaned hashtags to delete!'); } $this->info(' '); $count = StatusHashtag::whereNull('status_visibility')->count(); if($count > 0) { $this->info("Found {$count} hashtags to fix ..."); $this->info(' '); } else { $this->info('Found no hashtags to fix!'); $this->info(' '); return; } $bar = $this->output->createProgressBar($count); $bar->start(); StatusHashtag::with('status') ->whereNull('status_visibility') ->chunk(50, function($tags) use($bar) { foreach($tags as $tag) { if(!$tag->status || !$tag->status->scope) { continue; } $tag->status_visibility = $tag->status->scope; $tag->save(); $bar->advance(); } }); $bar->finish(); $this->info(' '); $this->info(' '); } }