From c7220158883734aef6c1c854e595b09be6549d4d Mon Sep 17 00:00:00 2001 From: David Trattnig <david.trattnig@o94.at> Date: Fri, 28 Aug 2020 19:58:57 +0200 Subject: [PATCH] Store additional details for clock. engine-clock#1 --- src/models.py | 36 ++++++++++++++------- src/rest/models/play_log.py | 54 ++++++++++++++++++++++++++++++- src/rest/models/playlist_entry.py | 32 ++++++++++++++++-- src/rest/models/track.py | 54 ++++++++++++++++++++++++++++++- src/rest/swagger/swagger.yaml | 26 +++++++++++++++ 5 files changed, 185 insertions(+), 17 deletions(-) diff --git a/src/models.py b/src/models.py index d9225d0..8fb6f75 100644 --- a/src/models.py +++ b/src/models.py @@ -46,8 +46,11 @@ class PlayLog(db.Model): track_title = Column(String(256)) track_duration = Column(Integer) track_type = Column(Integer) + track_num = Column(Integer) + playlist_id = Column(Integer) schedule_id = Column(Integer) - show_name = Column(String(256)) + show_id = Column(Integer) + show_name = Column(String(256)) log_source = Column(Integer) # The play-out source which this log is coming from (e.g. engine1, engine2) is_synced = Column(Boolean) # Only relevant for main nodes, in a multi-node setup @@ -63,7 +66,10 @@ class PlayLog(db.Model): self.track_title = data.track_title self.track_duration = data.track_duration self.track_type = data.track_type + self.track_num = data.track_num + self.playlist_id = data.playlist_id self.schedule_id = data.schedule_id + self.show_id = data.show_id self.show_name = data.show_name self.log_source = data.log_source self.is_synced = False @@ -206,7 +212,10 @@ class TrackSchema(ma.SQLAlchemySchema): "track_title", "track_duration", "track_type", + "track_num", + "playlist_id", "schedule_id", + "show_id", "show_name" ) @@ -362,17 +371,20 @@ class ClockInfo(db.Model): current_track = PlayLog.select_current() track_schema = TrackSchema() - info["log_source"] = data.log_source - info["log_time"] = data.log_time - - if current_track: - info["current_track"] = track_schema.dump(current_track) - if data.current_playlist: - info["current_playlist"] = json.loads(data.current_playlist) - if data.current_schedule: - info["current_schedule"] = json.loads(data.current_schedule) - if data.next_schedule: - info["next_schedule"] = json.loads(data.next_schedule) + if not data: + self.log.warn("No clock info data available!") + else: + info["log_source"] = data.log_source + info["log_time"] = data.log_time + + if current_track: + info["current_track"] = track_schema.dump(current_track) + if data.current_playlist: + info["current_playlist"] = json.loads(data.current_playlist) + if data.current_schedule: + info["current_schedule"] = json.loads(data.current_schedule) + if data.next_schedule: + info["next_schedule"] = json.loads(data.next_schedule) return info diff --git a/src/rest/models/play_log.py b/src/rest/models/play_log.py index e472a5a..05145af 100644 --- a/src/rest/models/play_log.py +++ b/src/rest/models/play_log.py @@ -14,7 +14,7 @@ class PlayLog(Model): Do not edit the class manually. """ - def __init__(self, track_start=None, track_artist=None, track_album=None, track_title=None, track_duration=None, track_type=None, schedule_id=None, show_id=None, show_name=None, log_source=None): # noqa: E501 + def __init__(self, track_start=None, track_artist=None, track_album=None, track_title=None, track_duration=None, track_type=None, track_num=None, playlist_id=None, schedule_id=None, show_id=None, show_name=None, log_source=None): # noqa: E501 """PlayLog - a model defined in Swagger :param track_start: The track_start of this PlayLog. # noqa: E501 @@ -29,6 +29,10 @@ class PlayLog(Model): :type track_duration: int :param track_type: The track_type of this PlayLog. # noqa: E501 :type track_type: int + :param track_num: The track_num of this PlayLog. # noqa: E501 + :type track_num: int + :param playlist_id: The playlist_id of this PlayLog. # noqa: E501 + :type playlist_id: int :param schedule_id: The schedule_id of this PlayLog. # noqa: E501 :type schedule_id: int :param show_id: The show_id of this PlayLog. # noqa: E501 @@ -45,6 +49,8 @@ class PlayLog(Model): 'track_title': str, 'track_duration': int, 'track_type': int, + 'track_num': int, + 'playlist_id': int, 'schedule_id': int, 'show_id': int, 'show_name': str, @@ -58,6 +64,8 @@ class PlayLog(Model): 'track_title': 'track_title', 'track_duration': 'track_duration', 'track_type': 'track_type', + 'track_num': 'track_num', + 'playlist_id': 'playlist_id', 'schedule_id': 'schedule_id', 'show_id': 'show_id', 'show_name': 'show_name', @@ -69,6 +77,8 @@ class PlayLog(Model): self._track_title = track_title self._track_duration = track_duration self._track_type = track_type + self._track_num = track_num + self._playlist_id = playlist_id self._schedule_id = schedule_id self._show_id = show_id self._show_name = show_name @@ -213,6 +223,48 @@ class PlayLog(Model): self._track_type = track_type + @property + def track_num(self): + """Gets the track_num of this PlayLog. + + + :return: The track_num of this PlayLog. + :rtype: int + """ + return self._track_num + + @track_num.setter + def track_num(self, track_num): + """Sets the track_num of this PlayLog. + + + :param track_num: The track_num of this PlayLog. + :type track_num: int + """ + + self._track_num = track_num + + @property + def playlist_id(self): + """Gets the playlist_id of this PlayLog. + + + :return: The playlist_id of this PlayLog. + :rtype: int + """ + return self._playlist_id + + @playlist_id.setter + def playlist_id(self, playlist_id): + """Sets the playlist_id of this PlayLog. + + + :param playlist_id: The playlist_id of this PlayLog. + :type playlist_id: int + """ + + self._playlist_id = playlist_id + @property def schedule_id(self): """Gets the schedule_id of this PlayLog. diff --git a/src/rest/models/playlist_entry.py b/src/rest/models/playlist_entry.py index 2842b2f..aaf6566 100644 --- a/src/rest/models/playlist_entry.py +++ b/src/rest/models/playlist_entry.py @@ -14,7 +14,7 @@ class PlaylistEntry(Model): Do not edit the class manually. """ - def __init__(self, track_start=None, track_artist=None, track_album=None, track_title=None, track_duration=None, track_type=None): # noqa: E501 + def __init__(self, track_start=None, track_artist=None, track_album=None, track_title=None, track_duration=None, track_type=None, track_num=None): # noqa: E501 """PlaylistEntry - a model defined in Swagger :param track_start: The track_start of this PlaylistEntry. # noqa: E501 @@ -29,6 +29,8 @@ class PlaylistEntry(Model): :type track_duration: int :param track_type: The track_type of this PlaylistEntry. # noqa: E501 :type track_type: int + :param track_num: The track_num of this PlaylistEntry. # noqa: E501 + :type track_num: int """ self.swagger_types = { 'track_start': datetime, @@ -36,7 +38,8 @@ class PlaylistEntry(Model): 'track_album': str, 'track_title': str, 'track_duration': int, - 'track_type': int + 'track_type': int, + 'track_num': int } self.attribute_map = { @@ -45,7 +48,8 @@ class PlaylistEntry(Model): 'track_album': 'track_album', 'track_title': 'track_title', 'track_duration': 'track_duration', - 'track_type': 'track_type' + 'track_type': 'track_type', + 'track_num': 'track_num' } self._track_start = track_start self._track_artist = track_artist @@ -53,6 +57,7 @@ class PlaylistEntry(Model): self._track_title = track_title self._track_duration = track_duration self._track_type = track_type + self._track_num = track_num @classmethod def from_dict(cls, dikt): @@ -192,3 +197,24 @@ class PlaylistEntry(Model): """ self._track_type = track_type + + @property + def track_num(self): + """Gets the track_num of this PlaylistEntry. + + + :return: The track_num of this PlaylistEntry. + :rtype: int + """ + return self._track_num + + @track_num.setter + def track_num(self, track_num): + """Sets the track_num of this PlaylistEntry. + + + :param track_num: The track_num of this PlaylistEntry. + :type track_num: int + """ + + self._track_num = track_num diff --git a/src/rest/models/track.py b/src/rest/models/track.py index 0633f1e..a778bca 100644 --- a/src/rest/models/track.py +++ b/src/rest/models/track.py @@ -14,7 +14,7 @@ class Track(Model): Do not edit the class manually. """ - def __init__(self, track_start=None, track_artist=None, track_album=None, track_title=None, track_duration=None, track_type=None, schedule_id=None, show_id=None, show_name=None): # noqa: E501 + def __init__(self, track_start=None, track_artist=None, track_album=None, track_title=None, track_duration=None, track_type=None, track_num=None, playlist_id=None, schedule_id=None, show_id=None, show_name=None): # noqa: E501 """Track - a model defined in Swagger :param track_start: The track_start of this Track. # noqa: E501 @@ -29,6 +29,10 @@ class Track(Model): :type track_duration: int :param track_type: The track_type of this Track. # noqa: E501 :type track_type: int + :param track_num: The track_num of this Track. # noqa: E501 + :type track_num: int + :param playlist_id: The playlist_id of this Track. # noqa: E501 + :type playlist_id: int :param schedule_id: The schedule_id of this Track. # noqa: E501 :type schedule_id: int :param show_id: The show_id of this Track. # noqa: E501 @@ -43,6 +47,8 @@ class Track(Model): 'track_title': str, 'track_duration': int, 'track_type': int, + 'track_num': int, + 'playlist_id': int, 'schedule_id': int, 'show_id': int, 'show_name': str @@ -55,6 +61,8 @@ class Track(Model): 'track_title': 'track_title', 'track_duration': 'track_duration', 'track_type': 'track_type', + 'track_num': 'track_num', + 'playlist_id': 'playlist_id', 'schedule_id': 'schedule_id', 'show_id': 'show_id', 'show_name': 'show_name' @@ -65,6 +73,8 @@ class Track(Model): self._track_title = track_title self._track_duration = track_duration self._track_type = track_type + self._track_num = track_num + self._playlist_id = playlist_id self._schedule_id = schedule_id self._show_id = show_id self._show_name = show_name @@ -208,6 +218,48 @@ class Track(Model): self._track_type = track_type + @property + def track_num(self): + """Gets the track_num of this Track. + + + :return: The track_num of this Track. + :rtype: int + """ + return self._track_num + + @track_num.setter + def track_num(self, track_num): + """Sets the track_num of this Track. + + + :param track_num: The track_num of this Track. + :type track_num: int + """ + + self._track_num = track_num + + @property + def playlist_id(self): + """Gets the playlist_id of this Track. + + + :return: The playlist_id of this Track. + :rtype: int + """ + return self._playlist_id + + @playlist_id.setter + def playlist_id(self, playlist_id): + """Sets the playlist_id of this Track. + + + :param playlist_id: The playlist_id of this Track. + :type playlist_id: int + """ + + self._playlist_id = playlist_id + @property def schedule_id(self): """Gets the schedule_id of this Track. diff --git a/src/rest/swagger/swagger.yaml b/src/rest/swagger/swagger.yaml index e618ac3..f31072b 100644 --- a/src/rest/swagger/swagger.yaml +++ b/src/rest/swagger/swagger.yaml @@ -384,6 +384,12 @@ components: track_type: type: integer example: 2 + track_num: + type: integer + example: 11 + playlist_id: + type: integer + example: 38 schedule_id: type: integer example: 23 @@ -396,8 +402,10 @@ components: example: track_album: '...And the Circus Leaves Town' show_id: 42 + playlist_id: 38 track_start: 2020-08-29T09:12:33.001Z track_title: El Rodeo + track_num: 11 show_name: Electronic Music from Brazil track_artist: Kyuss track_duration: 303 @@ -427,6 +435,12 @@ components: track_type: type: integer example: 2 + track_num: + type: integer + example: 11 + playlist_id: + type: integer + example: 38 schedule_id: type: integer example: 23 @@ -442,8 +456,10 @@ components: example: track_album: Bricolage show_id: 42 + playlist_id: 38 track_start: 2020-08-29T09:12:33.001Z track_title: Chomp Samba + track_num: 11 show_name: Electronic Music from Brazil log_source: 1 track_artist: Amon Tobin @@ -492,12 +508,14 @@ components: - track_album: Bricolage track_start: 2020-08-29T09:12:33.001Z track_title: Chomp Samba + track_num: 7 track_artist: Amon Tobin track_duration: 808 track_type: 2 - track_album: Bricolage track_start: 2020-08-29T09:12:33.001Z track_title: Chomp Samba + track_num: 7 track_artist: Amon Tobin track_duration: 808 track_type: 2 @@ -505,8 +523,10 @@ components: current_track: track_album: Bricolage show_id: 42 + playlist_id: 38 track_start: 2020-08-29T09:12:33.001Z track_title: Chomp Samba + track_num: 11 show_name: Electronic Music from Brazil log_source: 1 track_artist: Amon Tobin @@ -577,12 +597,14 @@ components: - track_album: Bricolage track_start: 2020-08-29T09:12:33.001Z track_title: Chomp Samba + track_num: 7 track_artist: Amon Tobin track_duration: 808 track_type: 2 - track_album: Bricolage track_start: 2020-08-29T09:12:33.001Z track_title: Chomp Samba + track_num: 7 track_artist: Amon Tobin track_duration: 808 track_type: 2 @@ -611,10 +633,14 @@ components: track_type: type: integer example: 2 + track_num: + type: integer + example: 7 example: track_album: Bricolage track_start: 2020-08-29T09:12:33.001Z track_title: Chomp Samba + track_num: 7 track_artist: Amon Tobin track_duration: 808 track_type: 2 -- GitLab