mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 15:07:49 +00:00
fix: reset cache for devices with different dimensions
This commit is contained in:
parent
ad5ff5d2c9
commit
27ea7d1496
2 changed files with 21 additions and 0 deletions
|
|
@ -115,4 +115,21 @@ class ImageGenerationService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function resetIfNotCacheable(?Plugin $plugin): void
|
||||||
|
{
|
||||||
|
if ($plugin?->id) {
|
||||||
|
if (
|
||||||
|
Device::query()
|
||||||
|
->where('width', '!=', 800)
|
||||||
|
->orWhere('height', '!=', 480)
|
||||||
|
->orWhere('rotate', '!=', 0)
|
||||||
|
->exists()
|
||||||
|
) {
|
||||||
|
// TODO cache image per device
|
||||||
|
$plugin->update(['current_image' => null]);
|
||||||
|
\Log::debug('Skip cache as devices with other dimensions exist');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
use App\Jobs\GenerateScreenJob;
|
use App\Jobs\GenerateScreenJob;
|
||||||
use App\Models\Device;
|
use App\Models\Device;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use App\Services\ImageGenerationService;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Blade;
|
use Illuminate\Support\Facades\Blade;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
@ -53,6 +54,9 @@ Route::get('/display', function (Request $request) {
|
||||||
$refreshTimeOverride = $playlistItem->playlist()->first()->refresh_time;
|
$refreshTimeOverride = $playlistItem->playlist()->first()->refresh_time;
|
||||||
$plugin = $playlistItem->plugin;
|
$plugin = $playlistItem->plugin;
|
||||||
|
|
||||||
|
// Reset cache if Devices with different dimensions exist
|
||||||
|
ImageGenerationService::resetIfNotCacheable($plugin);
|
||||||
|
|
||||||
// Check and update stale data if needed
|
// Check and update stale data if needed
|
||||||
if ($plugin->isDataStale() || $plugin->current_image == null) {
|
if ($plugin->isDataStale() || $plugin->current_image == null) {
|
||||||
$plugin->updateDataPayload();
|
$plugin->updateDataPayload();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue