Updated the rebuild:tags command with a progress bar.

This commit is contained in:
Peter Deltchev 2015-09-24 09:59:45 -07:00
parent 7d76e2d74d
commit ae39784708

View file

@ -41,13 +41,21 @@ class RebuildTags extends Command
if ($this->argument('trackId')) { if ($this->argument('trackId')) {
$track = Track::findOrFail($this->argument('trackId')); $track = Track::findOrFail($this->argument('trackId'));
$tracks = [$track]; $tracks = [$track];
} else { } else {
$tracks = Track::whereNotNull('published_at')->get(); $tracks = Track::whereNotNull('published_at')->orderBy('id', 'asc')->get();
} }
$bar = $this->output->createProgressBar(sizeof($tracks));
foreach($tracks as $track) { foreach($tracks as $track) {
$this->comment('Rewriting tags for track #'.$track->id.'...'); $this->comment('Rewriting tags for track #'.$track->id.'...');
$track->updateTags(); $track->updateTags();
} $bar->advance();
$this->line('');
}
$bar->finish();
$this->line('');
} }
} }