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
bf5449ce
Commit
bf5449ce
authored
5 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Fixed filters and simplified using timestamps.
parent
f4c48bd5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/scheduling/calender_fetcher.py
+26
-28
26 additions, 28 deletions
modules/scheduling/calender_fetcher.py
with
26 additions
and
28 deletions
modules/scheduling/calender_fetcher.py
+
26
−
28
View file @
bf5449ce
...
...
@@ -6,7 +6,7 @@ import simplejson
from
datetime
import
datetime
,
timedelta
#from modules.models.schedule import Schedule
from
modules.base.simpleutil
import
SimpleUtil
class
CalendarFetcher
:
url
=
dict
()
...
...
@@ -259,51 +259,49 @@ class CalendarFetcher:
def
remove_data_more_than_24h_in_the_future
(
self
,
schedule
_from_pv
):
def
remove_data_more_than_24h_in_the_future
(
self
,
schedule
s
):
"""
Removes entries 24h in the future and 12 hours in the past.
Note: This might influence resuming (in case of a crash)
single schedules which are longer than 12 hours long.
Think e.g. live broadcasts.
"""
act_list
=
[]
now
=
datetime
.
now
()
now_plus_24hours
=
now
+
timedelta
(
hours
=
24
)
for
s
in
schedule_from_pv
:
date_start
=
datetime
.
strptime
(
s
[
"
start
"
],
"
%Y-%m-%dT%H:%M:%S
"
)
items
=
[]
now
=
SimpleUtil
.
timestamp
()
now_plus_24hours
=
now
+
(
12
*
60
*
60
)
now_minus_12hours
=
now
-
(
12
*
60
*
60
)
# append only elements which are close enough to now
if
date_start
<=
now_plus_24hours
and
date_start
>=
now
-
timedelta
(
hours
=
12
):
act_list
.
append
(
s
)
for
s
in
schedules
:
start_time
=
datetime
.
strptime
(
s
[
"
start
"
],
"
%Y-%m-%dT%H:%M:%S
"
)
start_time
=
SimpleUtil
.
timestamp
(
start_time
)
return
act_list
if
start_time
<=
now_plus_24hours
and
start_time
>=
now_minus_12hours
:
items
.
append
(
s
)
return
items
def
remove_data_in_the_past
(
self
,
schedule
_from_pv
):
def
remove_data_in_the_past
(
self
,
schedule
s
):
"""
Removes all schedules from the past, except the one which is
currently playing.
"""
act_list
=
[]
now
=
datetime
.
now
()
count
=
len
(
schedule_from_pv
)
for
index
,
curr
in
enumerate
(
schedule_from_pv
):
date_start
=
datetime
.
strptime
(
curr
[
"
start
"
],
"
%Y-%m-%dT%H:%M:%S
"
)
if
index
+
1
<
count
:
date_next_start
=
datetime
.
strptime
(
schedule_from_pv
[
index
+
1
][
"
start
"
],
"
%Y-%m-%dT%H:%M:%S
"
)
items
=
[]
now
=
SimpleUtil
.
timestamp
()
for
s
in
schedules
:
start_time
=
datetime
.
strptime
(
s
[
"
start
"
],
"
%Y-%m-%dT%H:%M:%S
"
)
start_time
=
SimpleUtil
.
timestamp
(
start_time
)
end_time
=
datetime
.
strptime
(
s
[
"
end
"
],
"
%Y-%m-%dT%H:%M:%S
"
)
end_time
=
SimpleUtil
.
timestamp
(
end_time
)
# Append all elements in the future
if
date_start
>=
now
:
act_list
.
append
(
curr
)
# Append the one which is now playing
elif
date_start
<
now
and
date_next_start
>=
now
:
act_list
.
append
(
curr
)
return
act_list
if
start_time
>=
now
:
items
.
append
(
s
)
# Append the one which is playing now
elif
start_time
<
now
<
end_time
:
items
.
append
(
s
)
return
items
# ------------------------------------------------------------------------------------------ #
...
...
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