mirror of
https://github.com/NotAShelf/air-quality-monitor.git
synced 2024-11-22 13:20:48 +00:00
updating
This commit is contained in:
parent
9df325b73e
commit
c6ff5cb22b
2 changed files with 5 additions and 4 deletions
|
@ -23,6 +23,6 @@ class AirQualityMonitor():
|
|||
"""Saves measurement to redis db"""
|
||||
redis_client.lpush('measurements', json.dumps(self.get_measurement(), default=str))
|
||||
|
||||
def get_last_n_measurements(self, n=10):
|
||||
def get_last_n_measurements(self):
|
||||
"""Returns the last n measurements in the list"""
|
||||
return [json.loads(x) for x in redis_client.lrange('measurements', -n, -1)]
|
||||
return [json.loads(x) for x in redis_client.lrange('measurements', 0, -1)]
|
||||
|
|
|
@ -23,9 +23,10 @@ atexit.register(lambda: scheduler.shutdown())
|
|||
def reconfigure_data(measurement):
|
||||
"""Reconfigures data for chart.js"""
|
||||
current = int(time.time())
|
||||
measurement = measurement.reverse()
|
||||
measurement = measurement[:30]
|
||||
measurement.reverse()
|
||||
return {
|
||||
'labels': [int((current - (x['time'])) / 60) for x in measurement],
|
||||
'labels': [x['measurement']['timestamp'] for x in measurement],
|
||||
'pm10': {
|
||||
'label': 'pm10',
|
||||
'data': [x['measurement']['pm10'] for x in measurement],
|
||||
|
|
Loading…
Reference in a new issue