[IMP] php: command to update artist images

refactor_total
Brett Spaulding 1 year ago
parent 9385a382ae
commit b57edf05f4

@ -0,0 +1,42 @@
<?php
namespace App\Console\Commands;
use App\Models\Artist;
use Illuminate\Console\Command;
use App\Utils\ImageUrl;
use Symfony\Component\Console\Helper\ProgressBar;
class UpdateArtistImages extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:update-artist-images';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Fetch and update artist images';
/**
* Execute the console command.
*/
public function handle()
{
$artists = Artist::all();
$bar = new ProgressBar($this->output, count($artists));
$bar->start();
foreach ($artists as $artist) {
$image_url = ImageUrl::modifyGoogleImageUrl($artist->thumbnail);
$image_file = ImageUrl::save_img_url($image_url);
$artist->image = $image_file;
$artist->save();
$bar->advance();
}
}
}

@ -122,13 +122,9 @@ document.addEventListener('alpine:init', () => {
Alpine.store('app', { Alpine.store('app', {
init() { init() {
// TODO: Poll for artists and queue // TODO: Poll for artists and queue
// this.Artists = [];
this.Queue = []; this.Queue = [];
// this.ArtistResults = [];
}, },
// Artists: [], // Rendered in the 'Artists' modal
// ArtistResults: [], // Rendered in the SWAL popup
Queue: [], // Rendered in the 'Queue' modal Queue: [], // Rendered in the 'Queue' modal
}); });
@ -138,6 +134,7 @@ document.addEventListener('alpine:init', () => {
}); });
$(document).ready(function () { $(document).ready(function () {
//Datatable for 'Catalog' menu
let ArtistTable = $('#artistsCatalogDatatable').DataTable({ let ArtistTable = $('#artistsCatalogDatatable').DataTable({
ajax: '/api/artists', ajax: '/api/artists',
type: 'get', type: 'get',
@ -165,10 +162,9 @@ $(document).ready(function () {
} }
], ],
}); });
// Polling for table update
// const getArtistTableInterval = setInterval(function() { const getArtistTableInterval = setInterval(function() {
// table.ajax.reload(); table.ajax.reload();
// }, 5000); }, 5000);
}); });

Loading…
Cancel
Save