feat(rotation): per-device image-selection preferences
CI / test (push) Has been cancelled

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:
2026-05-07 16:37:14 -04:00
parent ba9625d45d
commit cf6623de67
26 changed files with 320 additions and 31 deletions
+30
View File
@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260507230003 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add device.rotation_mode + device.prioritize_never_shown — image-selection preferences exposed in the PWA settings sheet';
}
public function up(Schema $schema): void
{
// Default 'oldest_upload' preserves the legacy hard-coded behavior so
// existing devices keep their current rotation order with no surprise.
$this->addSql("ALTER TABLE device ADD rotation_mode VARCHAR(32) NOT NULL DEFAULT 'oldest_upload'");
$this->addSql('ALTER TABLE device ADD prioritize_never_shown BOOLEAN NOT NULL DEFAULT FALSE');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE device DROP COLUMN rotation_mode');
$this->addSql('ALTER TABLE device DROP COLUMN prioritize_never_shown');
}
}