Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aura-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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Lars Kruse
aura-engine
Commits
718a29a4
Commit
718a29a4
authored
4 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Populate "timeslot_id" by default.
#50
parent
1adfdcd3
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/calender_fetcher.py
+18
-15
18 additions, 15 deletions
src/scheduling/calender_fetcher.py
with
18 additions
and
15 deletions
src/scheduling/calender_fetcher.py
+
18
−
15
View file @
718a29a4
...
@@ -121,7 +121,7 @@ class CalendarFetcher:
...
@@ -121,7 +121,7 @@ class CalendarFetcher:
Returns:
Returns:
([Timeslot]): An array of timeslots
([Timeslot]): An array of timeslots
"""
"""
timeslot
=
None
timeslot
s
=
None
headers
=
{
"
content-type
"
:
"
application/json
"
}
headers
=
{
"
content-type
"
:
"
application/json
"
}
try
:
try
:
...
@@ -131,15 +131,15 @@ class CalendarFetcher:
...
@@ -131,15 +131,15 @@ class CalendarFetcher:
self
.
logger
.
critical
(
SU
.
red
(
"
HTTP Status: %s | Timeslots could not be fetched! Response: %s
"
%
\
self
.
logger
.
critical
(
SU
.
red
(
"
HTTP Status: %s | Timeslots could not be fetched! Response: %s
"
%
\
(
str
(
response
.
status_code
),
response
.
text
)))
(
str
(
response
.
status_code
),
response
.
text
)))
return
None
return
None
timeslot
=
response
.
json
()
timeslot
s
=
response
.
json
()
except
Exception
as
e
:
except
Exception
as
e
:
self
.
logger
.
critical
(
SU
.
red
(
"
Error while requesting timeslots from Steering!
"
),
e
)
self
.
logger
.
critical
(
SU
.
red
(
"
Error while requesting timeslots from Steering!
"
),
e
)
if
not
timeslot
:
if
not
timeslot
s
:
self
.
logger
.
error
(
SU
.
red
(
"
Got no timeslot via Playout API (Steering)!
"
))
self
.
logger
.
error
(
SU
.
red
(
"
Got no timeslot
s
via Playout API (Steering)!
"
))
return
None
return
None
return
self
.
remove_unnecessary_data
(
timeslot
)
return
self
.
polish_timeslots
(
timeslot
s
)
...
@@ -222,24 +222,27 @@ class CalendarFetcher:
...
@@ -222,24 +222,27 @@ class CalendarFetcher:
"""
"""
playlist_id
=
str
(
timeslot
[
id_name
])
playlist_id
=
str
(
timeslot
[
id_name
])
if
not
playlist_id
or
playlist_id
==
"
None
"
:
if
not
playlist_id
or
playlist_id
==
"
None
"
:
self
.
logger
.
debug
(
"
No value defined for
'
%s
'
in timeslot
'
#%s
'"
%
(
id_name
,
timeslot
[
"
timeslot_
id
"
]))
self
.
logger
.
debug
(
"
No value defined for
'
%s
'
in timeslot
'
#%s
'"
%
(
id_name
,
timeslot
[
"
id
"
]))
return
None
return
None
return
playlist_id
return
playlist_id
def
remove_unnecessary_data
(
self
,
timeslot
):
def
polish_timeslots
(
self
,
timeslot
s
):
"""
"""
Removes all timeslots which are not relevant for
Removes all timeslots which are not relevant for
further processing,
further processing
.
and transparent timeslot ID assigment for more expressive use
.
"""
"""
count_before
=
len
(
timeslot
)
count_before
=
len
(
timeslots
)
timeslot
=
self
.
remove_data_more_than_24h_in_the_future
(
timeslot
)
timeslots
=
self
.
remove_data_more_than_24h_in_the_future
(
timeslots
)
timeslot
=
self
.
remove_data_in_the_past
(
timeslot
)
timeslots
=
self
.
remove_data_in_the_past
(
timeslots
)
count_after
=
len
(
timeslot
)
count_after
=
len
(
timeslots
)
self
.
logger
.
debug
(
"
Removed %d unnecessary timeslots from response. Timeslots left: %d
"
%
((
count_before
-
count_after
),
count_after
))
for
t
in
timeslots
:
t
[
"
timeslot_id
"
]
=
t
[
"
id
"
]
return
timeslots
self
.
logger
.
debug
(
"
Removed %d unnecessary timeslots from response. Entries left: %d
"
%
((
count_before
-
count_after
),
count_after
))
return
timeslot
def
remove_data_more_than_24h_in_the_future
(
self
,
timeslots
):
def
remove_data_more_than_24h_in_the_future
(
self
,
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