Adds two settings exposed in the PWA frame-settings sheet:
- rotationMode (enum: random | least_recently_shown | oldest_upload |
newest_upload). Default oldest_upload preserves the legacy
hard-coded sort, so existing devices behave identically until the
user changes it.
- prioritizeNeverShown (bool). When set, the candidate set is narrowed
to never-shown images first (if any exist) before the mode runs —
useful for "burn through new uploads before re-shuffling the catalog."
RotationService pipeline:
1. Pull approved/ready pool.
2. Drop the last `uniquenessWindow` served (existing).
3. If prioritizeNeverShown AND any candidates have never been served,
narrow to those.
4. Apply the selection mode.
Backend: enum, entity columns + accessors, migration, serializer,
PATCH validator. Frontend: types, stores, settings sheet section
(dropdown + checkbox), test fixtures, save-flow test.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Entity\RenderedAsset;
|
||||
use App\Entity\User;
|
||||
use App\Enum\Orientation;
|
||||
use App\Enum\RenderStatus;
|
||||
use App\Enum\RotationMode;
|
||||
use App\Service\DeviceSerializer;
|
||||
use App\Service\MercurePublisher;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@@ -119,6 +120,18 @@ class DeviceApiController extends AbstractController
|
||||
$device->setUniquenessWindow(max(1, (int) $body['uniquenessWindow']));
|
||||
}
|
||||
|
||||
if (isset($body['rotationMode'])) {
|
||||
$mode = RotationMode::tryFrom((string) $body['rotationMode']);
|
||||
if (!$mode) {
|
||||
return $this->json(['error' => 'Invalid rotation mode'], Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
$device->setRotationMode($mode);
|
||||
}
|
||||
|
||||
if (array_key_exists('prioritizeNeverShown', $body)) {
|
||||
$device->setPrioritizeNeverShown((bool) $body['prioritizeNeverShown']);
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
$payload = $this->serializer->serialize($device);
|
||||
$this->mercure->publishDevice((int) $device->getId(), $payload);
|
||||
|
||||
Reference in New Issue
Block a user