Make dummy probe use tighter pattern for random readings

to make for a more reasonable-looking graph
This commit is contained in:
Lance Edgar 2018-10-20 04:17:42 -05:00
parent 44d012b3fd
commit 1f8507508a
2 changed files with 23 additions and 1 deletions

View file

@ -297,6 +297,16 @@ class Probe(Base):
def __str__(self):
return self.description
def last_reading(self):
"""
Returns the reading which was taken most recently for this probe.
"""
session = orm.object_session(self)
return session.query(Reading)\
.filter(Reading.probe == self)\
.order_by(Reading.taken.desc())\
.first()
def start_status(self, status, time):
"""
Update the "started" timestamp field for the given status. This is
@ -413,6 +423,7 @@ class Reading(Base):
""",
backref=orm.backref(
'readings',
order_by='Reading.taken',
cascade='all, delete-orphan'))
taken = sa.Column(sa.DateTime(), nullable=False, default=datetime.datetime.utcnow)