mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-14 07:27:47 +00:00
Move current_image caching to plugins
This commit is contained in:
parent
6bfd9a2d8b
commit
4aa67ce02d
6 changed files with 18 additions and 18 deletions
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Device;
|
||||
use App\Models\PlaylistItem;
|
||||
use App\Models\Plugin;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Spatie\Browsershot\Browsershot;
|
||||
|
|
@ -62,8 +62,8 @@ class CommonFunctions
|
|||
public static function cleanupFolder(): void
|
||||
{
|
||||
$activeDeviceImageUuids = Device::pluck('current_screen_image')->filter()->toArray();
|
||||
$activePlaylistImageUuids = PlaylistItem::pluck('current_image')->filter()->toArray();
|
||||
$activeImageUuids = array_merge($activeDeviceImageUuids, $activePlaylistImageUuids);
|
||||
$activePluginImageUuids = Plugin::pluck('current_image')->filter()->toArray();
|
||||
$activeImageUuids = array_merge($activeDeviceImageUuids, $activePluginImageUuids);
|
||||
|
||||
$files = Storage::disk('public')->files('/images/generated/');
|
||||
foreach ($files as $file) {
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\PlaylistItem;
|
||||
use App\Models\Plugin;
|
||||
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
|
||||
class GeneratePluginJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ class GeneratePlaylistItemJob implements ShouldQueue
|
|||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly int $playlistItemId,
|
||||
private readonly int $pluginId,
|
||||
private readonly string $markup
|
||||
) {}
|
||||
|
||||
|
|
@ -28,8 +28,8 @@ class GeneratePlaylistItemJob implements ShouldQueue
|
|||
{
|
||||
$newImageUuid = CommonFunctions::generateImage($this->markup);
|
||||
|
||||
PlaylistItem::find($this->playlistItemId)->update(['current_image' => $newImageUuid]);
|
||||
\Log::info("Playlist item $this->playlistItemId: updated with new image: $newImageUuid");
|
||||
Plugin::find($this->pluginId)->update(['current_image' => $newImageUuid]);
|
||||
\Log::info("Plugin $this->pluginId: updated with new image: $newImageUuid");
|
||||
|
||||
CommonFunctions::cleanupFolder();
|
||||
}
|
||||
|
|
@ -15,7 +15,6 @@ class PlaylistItem extends Model
|
|||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
'last_displayed_at' => 'datetime',
|
||||
'current_image' => 'string',
|
||||
];
|
||||
|
||||
public function playlist(): BelongsTo
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class Plugin extends Model
|
|||
'data_payload' => 'json',
|
||||
'data_payload_updated_at' => 'datetime',
|
||||
'is_native' => 'boolean',
|
||||
'current_image' => 'string',
|
||||
];
|
||||
|
||||
protected static function boot()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue