Skip to content
Snippets Groups Projects
Commit 25b2bf79 authored by David Trattnig's avatar David Trattnig
Browse files

Model for activity and health log.

parent 4f12d39d
No related branches found
No related tags found
No related merge requests found
......@@ -147,6 +147,7 @@ class PlayLog(db.Model):
return "Track [track_start: %s, track_title: %s]" % (str(self.track_start), str(self.track_title))
class PlayLogSchema(ma.SQLAlchemyAutoSchema):
"""
Schema for playlog entries.
......@@ -156,6 +157,7 @@ class PlayLogSchema(ma.SQLAlchemyAutoSchema):
sqla_session = db.session
class TrackSchema(ma.SQLAlchemySchema):
"""
Schema for trackservice entries.
......@@ -170,3 +172,62 @@ class TrackSchema(ma.SQLAlchemySchema):
"track_title"
)
class ActivityLog(db.Model):
"""
Table holding a log of play-out source active and sync states.
"""
__tablename__ = 'activity_log'
# Primary Key
log_time = Column(DateTime, primary_key=True)
# Columns
source_number = Column(Integer)
is_synced = Column(Boolean)
def __init__(self, source_number):
"""
Initializes a activity entry
"""
self.log_time = datetime.datetime.now()
self.source_number = source_number
self.is_synced = False
def save(self):
db.session.add(self)
db.session.commit()
class HealthHistory(db.Model):
"""
Table holding an history of health information for sources.
"""
__tablename__ = 'health_history'
# Primary Key
log_time = Column(DateTime, primary_key=True)
# Columns
source_number = Column(Integer)
is_healthy = Column(Boolean)
health_info = Column(String(2048))
def __init__(self, data):
"""
Initializes an health entry.
"""
self.log_time = datetime.datetime.now()
self.source_number = source_number
def save(self):
db.session.add(self)
db.session.commit()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment