diff --git a/site/app/Http/Controllers/ArtistController.php b/site/app/Http/Controllers/ArtistController.php index 0827d6e..1492262 100644 --- a/site/app/Http/Controllers/ArtistController.php +++ b/site/app/Http/Controllers/ArtistController.php @@ -23,6 +23,7 @@ public function index() $user = auth()->user(); $artists = Artist::whereHas('artworks') ->withCount('artworks') + ->withCount('episodes') ->orderBy('artworks_count', 'desc') ->paginate(100); $podcasts = Podcast::where('published', true)->get(); @@ -65,6 +66,8 @@ public function show(Request $request, $slug) { $user = auth()->user(); $artist = Artist::where('slug', $slug) + ->withCount('episodes') + ->withCount('artworks') ->firstOrFail(); $artworks = Artwork::where('artist_id', $artist->id) ->with('episode') diff --git a/site/app/Jobs/OptimizeArtistHeaderJob.php b/site/app/Jobs/OptimizeArtistHeaderJob.php new file mode 100644 index 0000000..e847476 --- /dev/null +++ b/site/app/Jobs/OptimizeArtistHeaderJob.php @@ -0,0 +1,36 @@ +path = $path; + } + + /** + * Execute the job. + */ + public function handle(): void + { + Log::info('Header: Optimizing ' . $this->path); + ImageOptimizer::optimize($this->path); + } +} diff --git a/site/app/Jobs/OptimizeAvatarJob.php b/site/app/Jobs/OptimizeAvatarJob.php new file mode 100644 index 0000000..fa054f0 --- /dev/null +++ b/site/app/Jobs/OptimizeAvatarJob.php @@ -0,0 +1,36 @@ +path = $path; + } + + /** + * Execute the job. + */ + public function handle(): void + { + Log::info('Avatar: Optimizing ' . $this->path); + ImageOptimizer::optimize($this->path); + } +} diff --git a/site/app/Livewire/Artist/Avatar.php b/site/app/Livewire/Artist/Avatar.php index 7076efe..0d08e6a 100644 --- a/site/app/Livewire/Artist/Avatar.php +++ b/site/app/Livewire/Artist/Avatar.php @@ -11,6 +11,8 @@ use Illuminate\Validation\Rules\File; use Illuminate\Http\RedirectResponse; use Livewire\Attributes\Validate; +use Illuminate\Support\Facades\Log; +use App\Jobs\OptimizeAvatarJob; class Avatar extends Component { @@ -32,7 +34,6 @@ public function save() { $disk = Storage::disk('static'); $avatar = $this->avatar->store('avatars', 'static'); - Image::load($disk->path($avatar)) ->manualCrop($this->width, $this->height, $this->x, $this->y) ->save(); @@ -40,7 +41,9 @@ public function save() ->width(350) ->height(350) ->save(); - ImageOptimizer::optimize($disk->path($avatar)); + Log::info('Avatar: Optimizing ' . $disk->path($avatar)); + OptimizeAvatarJob::dispatchSync($disk->path($avatar)); + //ImageOptimizer::optimize($disk->path($avatar)); auth()->user()->artists()->first()->update(compact('avatar')); $this->avatar = null; return redirect(request()->header('Referer')); diff --git a/site/app/Livewire/Artist/Header.php b/site/app/Livewire/Artist/Header.php index ae5cae5..a0dff07 100644 --- a/site/app/Livewire/Artist/Header.php +++ b/site/app/Livewire/Artist/Header.php @@ -11,6 +11,8 @@ use Illuminate\Validation\Rules\File; use Illuminate\Http\RedirectResponse; use Livewire\Attributes\Validate; +use Illuminate\Support\Facades\Log; +use App\Jobs\OptimizeArtistHeaderJob; class Header extends Component { @@ -32,7 +34,6 @@ public function save() { $disk = Storage::disk('static'); $header = $this->header->store('artist_headers', 'static'); - Image::load($disk->path($header)) ->manualCrop($this->width, $this->height, $this->x, $this->y) ->save(); @@ -40,7 +41,8 @@ public function save() ->width(270) ->height(185) ->save(); - ImageOptimizer::optimize($disk->path($header)); + Log::info('Avatar: Optimizing ' . $disk->path($header)); + OptimizeArtistHeaderJob::dispatchSync($disk->path($header)); auth()->user()->artists()->first()->update(compact('header')); $this->header = null; return redirect(request()->header('Referer')); diff --git a/site/resources/views/profile/partials/single-artist-card.blade.php b/site/resources/views/profile/partials/single-artist-card.blade.php index bd41790..424fb67 100644 --- a/site/resources/views/profile/partials/single-artist-card.blade.php +++ b/site/resources/views/profile/partials/single-artist-card.blade.php @@ -21,7 +21,8 @@ @endif
- {{ number_format($artist->artworks->count()) }} Submitted Artworks + {{ number_format($artist->artworks_count) }} Submitted Artworks
+ {{ number_format($artist->episodes_count) }} Artworks Selected