feat(backend): signage schedules: which playlist plays when, switching by itself (platform-v2 step 5.4d)

- signage_schedules (Alembic 0030): entries {playlist, days, hours (may pass
  midnight), dates, priority} and a fallback playlist. A screen's `schedule`
  (ref) wins over its single playlist.
- services/signage_schedule.pick (pure): highest priority, then the most
  specific (dates > days > hours), then the later entry; no match → fallback.
- GET /api/signage/screen with a schedule: the schedule (with the venue's time
  zone) and every playlist in it, `playlist` = the one playing now, so the
  player can switch while the server is down.
- schedule_worker (signage module, 30 s) tells a screen when its pick changes.
- /api/signage/schedules CRUD (playing now, the screens on it); deleting a
  playlist takes it out of schedules; changes reach screens through schedules.
- Devices page: a signage screen's Schedule.
- tests: test_signage_schedule.py (6); 526 passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 18:47:33 +02:00
co-authored by Claude Opus 5.5
parent b5951ba373
commit 0d766d3c86
15 changed files with 493 additions and 30 deletions
+14
View File
@@ -51,3 +51,17 @@ class SignageSlide(Base):
content = Column(JSON, nullable=False, default=dict)
playlist = relationship("SignagePlaylist", back_populates="slides")
class SignageSchedule(Base):
"""Which playlist plays when (5.4d): entries matched in venue time (services/signage_schedule.py),
the fallback when none matches. A screen with a schedule plays it instead of a single playlist."""
__tablename__ = "signage_schedules"
id = Column(Integer, primary_key=True, index=True)
name = Column(String, nullable=False)
fallback_playlist_id = Column(Integer, ForeignKey("signage_playlists.id", ondelete="SET NULL"), nullable=True)
# [{playlist_id, days, time_from, time_to, date_from, date_to, priority}]
entries = Column(JSON, nullable=False, default=list)
created_at = Column(UTCDateTime, default=utcnow, nullable=False)
updated_at = Column(UTCDateTime, default=utcnow, onupdate=utcnow, nullable=False)