- 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>
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
"""Signage schedules (plan step 5.4d): which playlist a screen plays when.
|
|
|
|
Revision ID: 0030_signage_schedules
|
|
Revises: 0029_signage
|
|
Create Date: 2026-11-17 21:00:00
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from core.timeutil import UTCDateTime
|
|
|
|
revision = '0030_signage_schedules'
|
|
down_revision = '0029_signage'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table('signage_schedules',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(), nullable=False),
|
|
sa.Column('fallback_playlist_id', sa.Integer(), nullable=True),
|
|
sa.Column('entries', sa.JSON(), nullable=False),
|
|
sa.Column('created_at', UTCDateTime(), nullable=False),
|
|
sa.Column('updated_at', UTCDateTime(), nullable=False),
|
|
sa.ForeignKeyConstraint(['fallback_playlist_id'], ['signage_playlists.id'], ondelete='SET NULL'),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
with op.batch_alter_table('signage_schedules', schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f('ix_signage_schedules_id'), ['id'], unique=False)
|
|
|
|
|
|
|
|
def downgrade() -> None:
|
|
with op.batch_alter_table('signage_schedules', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_signage_schedules_id'))
|
|
|
|
op.drop_table('signage_schedules')
|