Add schedule slots engine (time-based and event-based scheduling)#2673
Open
Alex1981-tech wants to merge 3 commits intoScreenly:masterfrom
Open
Add schedule slots engine (time-based and event-based scheduling)#2673Alex1981-tech wants to merge 3 commits intoScreenly:masterfrom
Alex1981-tech wants to merge 3 commits intoScreenly:masterfrom
Conversation
Introduce a schedule slot system that enables time-of-day and event-based content scheduling. When ScheduleSlot records exist, the viewer switches to "schedule mode" with slot priority (event > time > default). Without any slots, legacy behaviour (asset.is_active()) is fully preserved. Key features: - ScheduleSlot model with three types: default, time, event - ScheduleSlotItem links assets to slots with optional duration override - Overnight slot support (e.g. 22:00-06:00) - Event slots: one-time, daily, or weekly recurrence with no-loop mode - Deadline timer interrupts current asset for on-time slot transitions - Full REST API with overlap validation and OpenAPI schema - Backward-compatible: zero slots = original Anthias behaviour Closes Screenly#2671 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace random.shuffle with secrets.SystemRandom.shuffle (security hotspot) - Deduplicate slot_end datetime construction in _calc_slot_deadline Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
d124413 to
49e0d32
Compare
- viewer/scheduling.py: apply ruff format (line break in _set_time) - tests/test_viewer.py: update generate_asset_list mock to return 4-tuple (playlist, deadline, no_loop, active_slot_id) matching the new schedule-aware signature Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Implements a schedule slot system that enables time-of-day and event-based content scheduling for Anthias, as proposed in #2671.
When
ScheduleSlotrecords exist the viewer switches to "schedule mode": only assets linked to the currently-active slot are played. When the table is empty the viewer falls back to legacy behaviour (asset.is_active()) — full backward compatibility is preserved.Key features
default(fallback),time(daily time window),event(one-time/recurring)days_of_weekrefers to the start daythreading.Timerinterrupts current asset for on-time slot transitions@extend_schemaFiles changed
anthias_app/models.pyScheduleSlot,ScheduleSlotItemmodels (~170 lines)anthias_app/migrations/0003_schedule_slots.pyviewer/scheduling.pySchedulerapi/serializers/schedule.pyapi/views/schedule.py@extend_schemaapi/urls/v2.pyanthias_app/admin.pyScheduleSlot+ScheduleSlotIteminlinetests/test_scheduler.pyapi/tests/test_schedule_endpoints.pyAPI endpoints
How it works
generate_asset_list()now returns a 4-tuple:(playlist, deadline, no_loop, active_slot_id)ScheduleSlotrecords exist → legacy path (unchanged)ScheduleSlotItemsSchedulerclass extended with deadline timer, no-loop support, and event completion handlingBackward compatibility
generate_asset_list()returns 4-tuple but legacy callers only need to update unpackingviewer/__init__.pyorviewer/media_player.pyTest plan
ruff checkpasses on all changed filesruff format --checkpasses on all changed filespython manage.py makemigrations --check— migration is up to datepython manage.py test tests.test_scheduler— scheduler tests passpython manage.py test api.tests.test_schedule_endpoints— API tests passCloses #2671
🤖 Generated with Claude Code