mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-12-22 13:34:55 +01:00
catch nen existing logfile for analytics page
This commit is contained in:
parent
f5e6b22f01
commit
2c13b3c62f
3 changed files with 12 additions and 7 deletions
|
@ -1,3 +1,3 @@
|
|||
__version__ = "4.1.6.b5"
|
||||
__version__ = "4.1.6.b6"
|
||||
__codename__ = "Groundhog Day"
|
||||
|
||||
|
|
|
@ -158,11 +158,14 @@ class LogController:
|
|||
dateparse = lambda dates: [datetime.datetime.strptime(d, '%Y-%m-%d %H:%M:%S') for d in dates]
|
||||
result = dict()
|
||||
for id in ids:
|
||||
all_filenames = glob.glob(os.path.join(self.logsFolderPath,f"sensor_{id}.log*"))
|
||||
df = pd.concat([pd.read_csv(f, parse_dates=['DateTime'], date_parser=dateparse, index_col='DateTime', names=['DateTime', 'Values'], header=None) for f in all_filenames])
|
||||
df = df.resample('60s').max()
|
||||
df = df.dropna()
|
||||
result[id] = {"time": df.index.astype(str).tolist(), "value":df.Values.tolist()}
|
||||
try:
|
||||
all_filenames = glob.glob(os.path.join(self.logsFolderPath,f"sensor_{id}.log*"))
|
||||
df = pd.concat([pd.read_csv(f, parse_dates=['DateTime'], date_parser=dateparse, index_col='DateTime', names=['DateTime', 'Values'], header=None) for f in all_filenames])
|
||||
df = df.resample('60s').max()
|
||||
df = df.dropna()
|
||||
result[id] = {"time": df.index.astype(str).tolist(), "value":df.Values.tolist()}
|
||||
except:
|
||||
pass
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ from cbpi.utils.utils import json_dumps
|
|||
from cbpi.api import request_mapping
|
||||
import os
|
||||
import json
|
||||
import logging
|
||||
class LogHttpEndpoints:
|
||||
|
||||
def __init__(self,cbpi):
|
||||
|
@ -189,7 +190,8 @@ class LogHttpEndpoints:
|
|||
description: successful operation.
|
||||
"""
|
||||
data = await request.json()
|
||||
return web.json_response(await self.cbpi.log.get_data2(data), dumps=json_dumps)
|
||||
values = await self.cbpi.log.get_data2(data)
|
||||
return web.json_response(values, dumps=json_dumps)
|
||||
|
||||
|
||||
@request_mapping(path="/{name}", method="DELETE", auth_required=False)
|
||||
|
|
Loading…
Reference in a new issue