Leverage common "now" value when sending emails from server
i.e. don't generate new "now" when sending an email, just use the "now" we established when starting to check the readings
This commit is contained in:
parent
71db57b2e0
commit
3aa4185de9
|
@ -183,13 +183,12 @@ class TempmonServerDaemon(Daemon):
|
|||
return False
|
||||
|
||||
def update_status(self, probe, status, reading=None):
|
||||
now = localtime(self.config)
|
||||
data = {
|
||||
'probe': probe,
|
||||
'status': self.enum.TEMPMON_PROBE_STATUS[status],
|
||||
'reading': reading,
|
||||
'taken': localtime(self.config, reading.taken, from_utc=True) if reading else None,
|
||||
'now': now,
|
||||
'now': localtime(self.config, self.now, from_utc=True),
|
||||
}
|
||||
|
||||
prev_status = probe.status
|
||||
|
@ -232,10 +231,10 @@ class TempmonServerDaemon(Daemon):
|
|||
# fetch last 90 minutes of readings
|
||||
session = orm.object_session(probe)
|
||||
recent_minutes = 90 # TODO: make configurable
|
||||
cutoff = now - datetime.timedelta(seconds=(60 * recent_minutes))
|
||||
cutoff = self.now - datetime.timedelta(seconds=(60 * recent_minutes))
|
||||
readings = session.query(tempmon.Reading)\
|
||||
.filter(tempmon.Reading.probe == probe)\
|
||||
.filter(tempmon.Reading.taken >= make_utc(cutoff))\
|
||||
.filter(tempmon.Reading.taken >= cutoff)\
|
||||
.order_by(tempmon.Reading.taken.desc())
|
||||
data['recent_minutes'] = recent_minutes
|
||||
data['recent_readings'] = readings
|
||||
|
|
Loading…
Reference in a new issue