Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
django-panik-nonstop
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
radiopanik
django-panik-nonstop
Commits
bd376cef
Commit
bd376cef
authored
Jul 02, 2020
by
fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stamina: wait 7 days before allowing same track
parent
c3f21f38
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
nonstop/app_settings.py
nonstop/app_settings.py
+4
-0
nonstop/management/commands/stamina.py
nonstop/management/commands/stamina.py
+10
-2
No files found.
nonstop/app_settings.py
View file @
bd376cef
...
...
@@ -34,5 +34,9 @@ class AppSettings:
def
ON_AIR_SWITCH_URL
(
self
):
return
self
.
get_setting
(
'ON_AIR_SWITCH_URL'
,
None
)
@
property
def
NO_REPEAT_DELAY
(
self
):
return
self
.
get_setting
(
'NO_REPEAT_DELAY'
,
7
)
app_settings
=
AppSettings
()
nonstop/management/commands/stamina.py
View file @
bd376cef
...
...
@@ -40,6 +40,10 @@ class Command(BaseCommand):
except
AttributeError
:
jingles
=
[]
recent_tracks_id
=
[
x
.
track_id
for
x
in
SomaLogLine
.
objects
.
exclude
(
on_air
=
False
).
filter
(
track__isnull
=
False
,
play_timestamp__gt
=
datetime
.
datetime
.
now
()
-
datetime
.
timedelta
(
days
=
app_settings
.
NO_REPEAT_DELAY
))]
t0
=
datetime
.
datetime
.
now
()
while
current_datetime
<
end_datetime
and
adjustment_counter
<
5
:
if
(
current_datetime
-
start_datetime
)
>
max_duration
and
(
...
...
@@ -57,8 +61,12 @@ class Command(BaseCommand):
track
=
Track
.
objects
.
filter
(
nonstop_zones
=
zone
,
duration__isnull
=
False
).
exclude
(
id__in
=
[
x
.
id
for
x
in
playlist
if
isinstance
(
x
,
Track
)]
id__in
=
recent_tracks_id
+
[
x
.
id
for
x
in
playlist
if
isinstance
(
x
,
Track
)]
).
order_by
(
'?'
).
first
()
if
track
is
None
:
# no track, reduce recent tracks exclusion
recent_tracks_id
=
recent_tracks_id
[:
len
(
recent_tracks_id
)
//
2
]
continue
playlist
.
append
(
track
)
current_datetime
=
start_datetime
+
sum
(
[
x
.
duration
for
x
in
playlist
],
datetime
.
timedelta
(
seconds
=
0
))
...
...
@@ -72,7 +80,7 @@ class Command(BaseCommand):
duration__gte
=
remaining_time
,
duration__lt
=
remaining_time
+
datetime
.
timedelta
(
seconds
=
1
)
).
exclude
(
id__in
=
[
x
.
id
for
x
in
playlist
if
isinstance
(
x
,
Track
)]
id__in
=
recent_tracks_id
+
[
x
.
id
for
x
in
playlist
if
isinstance
(
x
,
Track
)]
).
order_by
(
'?'
).
first
()
if
track
:
# found a track
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment