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
96bfc486
Commit
96bfc486
authored
4 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Reuse timeslots which got just stored. #41
parent
51cc9001
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/scheduling/programme.py
+15
-12
15 additions, 12 deletions
src/scheduling/programme.py
with
15 additions
and
12 deletions
src/scheduling/programme.py
+
15
−
12
View file @
96bfc486
...
@@ -70,17 +70,13 @@ class ProgrammeService():
...
@@ -70,17 +70,13 @@ class ProgrammeService():
self
.
api_fetcher
.
start
()
self
.
api_fetcher
.
start
()
response
=
self
.
api_fetcher
.
get_fetched_data
()
response
=
self
.
api_fetcher
.
get_fetched_data
()
# Reset last successful fetch state
lsf
=
self
.
last_successful_fetch
self
.
last_successful_fetch
=
None
if
response
is
None
:
if
response
is
None
:
msg
=
SU
.
red
(
"
Trying to load programme from Engine Database, because ApiFetcher returned an empty response.
"
)
msg
=
SU
.
red
(
"
Trying to load programme from Engine Database, because ApiFetcher returned an empty response.
"
)
self
.
logger
.
warning
(
msg
)
self
.
logger
.
warning
(
msg
)
elif
type
(
response
)
is
list
:
elif
type
(
response
)
is
list
:
if
len
(
response
)
>
0
:
if
len
(
response
)
>
0
:
self
.
last_successful_fetch
=
datetime
.
now
()
self
.
last_successful_fetch
=
datetime
.
now
()
self
.
programme_store
.
store_timeslots
(
response
)
self
.
timeslots
=
self
.
programme_store
.
store_timeslots
(
response
)
self
.
logger
.
info
(
SU
.
green
(
f
"
Finished fetching current programme from API (
{
len
(
response
)
}
timeslots)
"
))
self
.
logger
.
info
(
SU
.
green
(
f
"
Finished fetching current programme from API (
{
len
(
response
)
}
timeslots)
"
))
else
:
else
:
self
.
logger
.
critical
(
"
Programme fetched from Steering/Tank has no entries!
"
)
self
.
logger
.
critical
(
"
Programme fetched from Steering/Tank has no entries!
"
)
...
@@ -91,10 +87,11 @@ class ProgrammeService():
...
@@ -91,10 +87,11 @@ class ProgrammeService():
msg
=
SU
.
red
(
"
Load programme from DB, because of an unknown response from ApiFetcher:
"
+
response
)
msg
=
SU
.
red
(
"
Load programme from DB, because of an unknown response from ApiFetcher:
"
+
response
)
self
.
logger
.
warning
(
msg
)
self
.
logger
.
warning
(
msg
)
# Always load latest programme from the database
# Load latest programme from the database
self
.
last_successful_fetch
=
lsf
if
not
self
.
timeslots
:
self
.
timeslots
=
self
.
programme_store
.
load_timeslots
()
self
.
timeslots
=
self
.
programme_store
.
load_timeslots
()
self
.
logger
.
info
(
SU
.
green
(
"
Finished loading current programme from database (%s timeslots)
"
%
str
(
len
(
self
.
timeslots
))))
self
.
logger
.
info
(
SU
.
green
(
"
Finished loading current programme from database (%s timeslots)
"
%
str
(
len
(
self
.
timeslots
))))
for
timeslot
in
self
.
timeslots
:
for
timeslot
in
self
.
timeslots
:
self
.
logger
.
debug
(
"
\t
Timeslot %s with Playlist %s
"
%
(
str
(
timeslot
),
str
(
timeslot
.
playlist
)))
self
.
logger
.
debug
(
"
\t
Timeslot %s with Playlist %s
"
%
(
str
(
timeslot
),
str
(
timeslot
.
playlist
)))
...
@@ -186,7 +183,7 @@ class ProgrammeService():
...
@@ -186,7 +183,7 @@ class ProgrammeService():
next_timeslots
.
append
(
timeslot
)
next_timeslots
.
append
(
timeslot
)
else
:
else
:
break
break
return
self
.
filter_scheduling_window
(
next_timeslots
)
return
self
.
filter_scheduling_window
(
next_timeslots
)
...
@@ -268,10 +265,13 @@ class ProgrammeStore():
...
@@ -268,10 +265,13 @@ class ProgrammeStore():
return
timeslots
return
timeslots
def
store_timeslots
(
self
,
fetched_timeslots
):
def
store_timeslots
(
self
,
fetched_timeslots
):
"""
"""
Stores the fetched timeslots to the database.
Stores the fetched timeslots to the database.
"""
"""
timeslots
=
[]
# Check if existing timeslots have been deleted
# Check if existing timeslots have been deleted
self
.
update_deleted_timeslots
(
fetched_timeslots
)
self
.
update_deleted_timeslots
(
fetched_timeslots
)
...
@@ -288,15 +288,18 @@ class ProgrammeStore():
...
@@ -288,15 +288,18 @@ class ProgrammeStore():
# Store the timeslot
# Store the timeslot
timeslot_db
=
self
.
store_timeslot
(
timeslot
)
timeslot_db
=
self
.
store_timeslot
(
timeslot
)
timeslots
.
append
(
timeslot_db
)
# Store playlists
to play
# Store
assigned
playlists
self
.
store_playlist
(
timeslot_db
,
timeslot_db
.
playlist_id
,
timeslot
[
"
playlist
"
])
self
.
store_playlist
(
timeslot_db
,
timeslot_db
.
playlist_id
,
timeslot
[
"
playlist
"
])
if
timeslot_db
.
schedule_fallback_id
:
if
timeslot_db
.
schedule_fallback_id
:
self
.
store_playlist
(
timeslot_db
,
timeslot_db
.
schedule_fallback_id
,
timeslot
[
"
schedule_fallback
"
])
self
.
store_playlist
(
timeslot_db
,
timeslot_db
.
schedule_fallback_id
,
timeslot
[
"
schedule_fallback
"
])
if
timeslot_db
.
show_fallback_id
:
if
timeslot_db
.
show_fallback_id
:
self
.
store_playlist
(
timeslot_db
,
timeslot_db
.
show_fallback_id
,
timeslot
[
"
show_fallback
"
])
self
.
store_playlist
(
timeslot_db
,
timeslot_db
.
show_fallback_id
,
timeslot
[
"
show_fallback
"
])
if
timeslot_db
.
station_fallback_id
:
if
timeslot_db
.
station_fallback_id
:
self
.
store_playlist
(
timeslot_db
,
timeslot_db
.
station_fallback_id
,
timeslot
[
"
station_fallback
"
])
self
.
store_playlist
(
timeslot_db
,
timeslot_db
.
station_fallback_id
,
timeslot
[
"
station_fallback
"
])
return
timeslots
...
...
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