Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
engine
Commits
c8b213a0
Commit
c8b213a0
authored
1 year ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
refactor: adapt according to new domain model
parent
4a0d869c
No related branches found
No related tags found
1 merge request
!35
ORM-less scheduling
Pipeline
#7708
failed
1 year ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/aura_engine/plugins/clock.py
+40
-34
40 additions, 34 deletions
src/aura_engine/plugins/clock.py
with
40 additions
and
34 deletions
src/aura_engine/plugins/clock.py
+
40
−
34
View file @
c8b213a0
...
...
@@ -36,8 +36,8 @@ import confuse
import
aura_engine.scheduling.domain
as
domain
from
aura_engine.base.api
import
SimpleRestApi
from
aura_engine.base.config
import
AuraConfig
from
aura_engine.base.lang
import
DotDict
from
aura_engine.resources
import
ResourceUtil
from
aura_engine.scheduling.scheduler
import
AuraScheduler
class
ClockInfoHandler
:
...
...
@@ -69,40 +69,46 @@ class ClockInfoHandler:
# This will be part of the coming "default station playlist" logic
pass
def
on_fallback_active
(
self
,
timeslot
,
fallback_name
):
def
on_fallback_active
(
self
,
timeslot
:
domain
.
Timeslot
):
"""
Call when a fallback is activated.
"""
if
timeslot
:
# Only update the current show to the fallback show,
# in case no timeslot is scheduled
return
self
.
logger
.
info
(
f
"
Fallback
'
{
fallback_name
}
'
activated, clock update required
"
)
fallback_show_id
=
self
.
config
.
general
.
fallback_show_id
fallback_show_name
=
self
.
config
.
general
.
fallback_show_name
Fallback means the station fallback audio source is played when:
1. no timeslot is available.
2. the current timefrome of the active timeslot provides no audio source/playlists.
# Interpolate timeslot-less slot
# TODO start time to be calculated based on previous timeslot (future station logic)
scheduler
=
self
.
engine
.
scheduler
upcoming_timeslots
:
[
domain
.
Timeslot
]
=
scheduler
.
timetable
.
get_next_timeslots
()
virtual_start_time
=
datetime
.
now
()
virtual_end_time
=
virtual_start_time
+
timedelta
(
hours
=
1
)
if
len
(
upcoming_timeslots
)
>
0
:
virtual_end_time
=
upcoming_timeslots
[
0
].
get_start
()
fallback_timeslot
=
DotDict
(
{
"
timeslotId
"
:
-
1
,
"
timeslotStart
"
:
virtual_start_time
,
"
timeslotEnd
"
:
virtual_end_time
,
"
showId
"
:
fallback_show_id
,
"
showName
"
:
fallback_show_name
,
"
playlistId
"
:
-
1
,
"
playlistType
"
:
-
1
,
}
)
self
.
post_clock_info
(
-
1
,
None
,
fallback_timeslot
,
upcoming_timeslots
)
TODO In the future case (1) should technically not happen, as
"
Virtual Timeslots
"
ensure
there is always some timeslot available, even without any playlists/media sources assigned.
Args:
timeslot (Timeslot): The active timeslot, if available. Can be `None`.
"""
# Check if we are within a valid timeslot
if
timeslot
:
self
.
logger
.
info
(
f
"
Fallback activated within timeslot
'
{
timeslot
}
'"
)
else
:
self
.
logger
.
info
(
"
Fallback activated outsite of timeslot
"
)
# Interpolate timeslot-less slot (in the future provided by Virtual Timeslots)
scheduler
:
AuraScheduler
=
self
.
engine
.
scheduler
upcoming_timeslots
:
list
[
domain
.
Timeslot
]
=
scheduler
.
timetable
.
get_next_timeslots
()
virtual_start_time
=
datetime
.
now
()
virtual_end_time
=
virtual_start_time
+
timedelta
(
hours
=
1
)
if
len
(
upcoming_timeslots
)
>
0
:
virtual_end_time
=
upcoming_timeslots
[
0
].
get_start
()
# Create fallback timeslot if event was triggered outsite of a valid timeslot
fallback_show_id
=
self
.
config
.
general
.
fallback_show_id
fallback_show_name
=
self
.
config
.
general
.
fallback_show_name
fallback_show
=
domain
.
Show
(
fallback_show_id
,
fallback_show_name
,
None
,
None
,
None
,
None
)
timeslot
=
domain
.
Timeslot
(
-
1
,
None
,
virtual_start_time
,
virtual_end_time
,
fallback_show
,
None
)
self
.
post_clock_info
(
timeslot
,
None
,
upcoming_timeslots
)
def
on_play
(
self
,
_
):
"""
...
...
@@ -122,13 +128,13 @@ class ClockInfoHandler:
active_playlist
:
domain
.
Playlist
=
active_timeslot
.
get_current_playlist
()
upcoming_timeslots
=
scheduler
.
timetable
.
get_next_timeslots
()
self
.
post_clock_info
(
active_
playlis
t
,
active_
timeslo
t
,
upcoming_timeslots
)
self
.
post_clock_info
(
active_
timeslo
t
,
active_
playlis
t
,
upcoming_timeslots
)
def
post_clock_info
(
self
,
active_playlist
:
domain
.
Playlist
,
active_timeslot
:
domain
.
Timeslot
,
upcoming_timeslots
:
[
domain
.
Timeslot
],
active_playlist
:
domain
.
Playlist
,
upcoming_timeslots
:
list
[
domain
.
Timeslot
],
):
"""
Post current information on timeslots and playlist to the Engine API clock endpoint.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment