Add image caching for playlist items

This commit is contained in:
zv0n 2025-05-01 19:06:28 +02:00
parent 81f721099c
commit 6bfd9a2d8b
6 changed files with 173 additions and 85 deletions

View file

@ -0,0 +1,37 @@
<?php
namespace App\Jobs;
use App\Models\PlaylistItem;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class GeneratePlaylistItemJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*/
public function __construct(
private readonly int $playlistItemId,
private readonly string $markup
) {}
/**
* Execute the job.
*/
public function handle(): void
{
$newImageUuid = CommonFunctions::generateImage($this->markup);
PlaylistItem::find($this->playlistItemId)->update(['current_image' => $newImageUuid]);
\Log::info("Playlist item $this->playlistItemId: updated with new image: $newImageUuid");
CommonFunctions::cleanupFolder();
}
}