Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine-api
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-api
Commits
238d5edc
Commit
238d5edc
authored
4 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
List playlog implementation.
parent
5c78fedc
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/models.py
+4
-2
4 additions, 2 deletions
src/models.py
src/rest/controllers/internal_controller.py
+4
-4
4 additions, 4 deletions
src/rest/controllers/internal_controller.py
src/service.py
+27
-1
27 additions, 1 deletion
src/service.py
with
35 additions
and
7 deletions
src/models.py
+
4
−
2
View file @
238d5edc
...
...
@@ -85,12 +85,14 @@ class PlayLog(db.Model):
@staticmethod
def
paginate
(
page
,
page_size
):
def
paginate
(
page
,
page_size
,
since_time
=
None
):
"""
Returns a list of entries for a given page.
Returns a list of entries for a given page
and an start time (optional)
.
"""
def
q
(
page
=
0
,
page_size
=
None
):
query
=
db
.
session
.
query
(
PlayLog
)
if
isinstance
(
since_time
,
datetime
.
datetime
):
query
=
query
.
filter
(
PlayLog
.
track_start
>=
since_time
)
listen
(
query
,
'
before_compile
'
,
apply_limit
(
page
,
page_size
),
retval
=
True
)
return
query
...
...
This diff is collapsed.
Click to expand it.
src/rest/controllers/internal_controller.py
+
4
−
4
View file @
238d5edc
...
...
@@ -2,13 +2,13 @@ import connexion
import
six
from
src.rest.models.clock_info
import
ClockInfo
# noqa: E501
org
.
joda
.
time
.
*
# noqa: E501
from
src.rest.models.health_info
import
HealthInfo
# noqa: E501
from
src.rest.models.play_log_entry
import
PlayLogEntry
# noqa: E501
from
src.rest.models.status_entry
import
StatusEntry
# noqa: E501
from
src.rest
import
util
from
flask
import
current_app
from
dateutil.parser
import
parse
def
activate_engine
(
engine_number
):
# noqa: E501
...
...
@@ -33,6 +33,7 @@ def add_playlog(): # noqa: E501
:rtype: PlayLogEntry
"""
service
=
current_app
.
config
[
'
SERVICE
'
]
service
.
store_playlog
()
def
clock_info
():
# noqa: E501
...
...
@@ -101,10 +102,9 @@ def list_playlog(date_time, page=None, limit=None): # noqa: E501
:rtype: List[PlayLogEntry]
"""
if
connexion
.
request
.
is_json
:
date_time
=
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
service
=
current_app
.
config
[
'
SERVICE
'
]
return
'
do some magic!
'
date_time
=
parse
(
date_time
)
return
service
.
list_playlog
(
page
,
limit
,
date_time
)
def
log_engine_health
(
engine_number
):
# noqa: E501
...
...
This diff is collapsed.
Click to expand it.
src/service.py
+
27
−
1
View file @
238d5edc
...
...
@@ -61,11 +61,37 @@ class ApiService():
(List[PlayLogEntry])
"""
if
not
size
or
size
>
50
or
size
<
1
:
size
=
20
tracklist
=
PlayLog
.
paginate
(
page
,
size
)
tracklist
=
PlayLog
.
paginate
(
page
,
size
,
None
)
tracklist_schema
=
TrackSchema
(
many
=
True
)
return
tracklist_schema
.
dump
(
tracklist
)
def
list_playlog
(
self
,
page
=
None
,
size
=
None
,
since_time
=
None
):
"""
Get paginated playlog entries for since the given timestamp.
Args:
since_time (datetime): Get entries after this timestamp (e.g. '2020-08-29T09:12:33.001Z')
page (Integer): The number of items to skip before starting to collect the result set
size (Integer): The numbers of items to return per page
Returns:
(List[PlayLogEntry])
"""
tracklist
=
PlayLog
.
paginate
(
page
,
size
,
since_time
)
tracklist_schema
=
TrackSchema
(
many
=
True
)
return
tracklist_schema
.
dump
(
tracklist
)
def
store_playlog
():
"""
Stores the passed playlog entry.
Returns:
(PlayLogEntry)
"""
def
clock_info
(
self
):
"""
Retrieves the currently playing playlist.
...
...
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