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
eefb99a5
Commit
eefb99a5
authored
5 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Clock API.
parent
ee076f3f
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
api.py
+45
-4
45 additions, 4 deletions
api.py
with
45 additions
and
4 deletions
api.py
+
45
−
4
View file @
eefb99a5
...
...
@@ -112,6 +112,7 @@ class EngineApi:
EngineApi
.
track_schema
=
TrackServiceSchema
()
EngineApi
.
report_schema
=
ReportSchema
(
many
=
True
)
EngineApi
.
schedule_schema
=
ScheduleSchema
(
many
=
True
)
EngineApi
.
clockdata_schema
=
ClockDataSchema
()
# Define API routes
self
.
api
.
add_resource
(
TrackServiceResource
,
config
.
api_prefix
+
"
/trackservice/
"
)
...
...
@@ -120,6 +121,7 @@ class EngineApi:
self
.
api
.
add_resource
(
TracksByDayResource
,
config
.
api_prefix
+
"
/trackservice/date/<string:date_string>
"
)
self
.
api
.
add_resource
(
ReportResource
,
config
.
api_prefix
+
"
/report/<string:year_month>
"
)
self
.
api
.
add_resource
(
UpcomingSchedulesResource
,
config
.
api_prefix
+
"
/schedule/upcoming
"
)
self
.
api
.
add_resource
(
ClockDataResource
,
config
.
api_prefix
+
"
/clock
"
)
self
.
logger
.
info
(
"
Engine API routes successfully set!
"
)
...
...
@@ -181,10 +183,6 @@ class TrackServiceSchema(ma.Schema):
"
schedule.musicfocus
"
,
"
schedule.is_repetition
"
,
"
schedule.show_id
"
,
"
schedule.show_name
"
,
"
schedule.show_hosts
"
,
"
track
"
,
"
track_start
"
,
...
...
@@ -192,6 +190,17 @@ class TrackServiceSchema(ma.Schema):
)
class
ClockDataSchema
(
ma
.
Schema
):
class
Meta
:
fields
=
(
"
current
"
,
"
next
"
,
"
track_id
"
,
"
track_start
"
,
"
track
"
)
class
ScheduleSchema
(
ma
.
Schema
):
class
Meta
:
fields
=
(
...
...
@@ -267,7 +276,39 @@ class TrackResource(Resource):
def
get
(
self
,
track_id
):
track
=
TrackService
.
select_one
(
track_id
)
return
EngineApi
.
track_schema
.
dump
(
track
)
class
ClockDataResource
(
Resource
):
logger
=
None
def
__init__
(
self
):
self
.
logger
=
logging
.
getLogger
(
"
engine-api
"
)
def
get
(
self
):
item
=
TrackService
.
select_current
()
next_schedule
=
Schedule
.
select_upcoming
(
1
)
if
next_schedule
:
next_schedule
=
next_schedule
[
0
].
as_dict
()
next_schedule
[
"
playlist
"
]
=
None
else
:
next_schedule
=
{}
clockdata
=
{
"
track_id
"
:
item
.
id
,
"
track_start
"
:
item
.
track_start
,
"
track
"
:
item
.
track
,
"
current
"
:
{},
"
next
"
:
next_schedule
}
if
item
.
schedule
:
clockdata
[
"
current
"
]
=
item
.
schedule
.
as_dict
()
if
item
.
schedule
.
playlist
:
clockdata
[
"
current
"
][
"
playlist
"
]
=
item
.
schedule
.
playlist
[
0
].
as_dict
()
clockdata
[
"
current
"
][
"
show
"
]
=
item
.
show
return
EngineApi
.
clockdata_schema
.
dump
(
clockdata
)
class
CurrentTrackResource
(
Resource
):
logger
=
None
...
...
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