From 62f35d53d2ff6a2095de78ef73bc5dbcef0cb4c3 Mon Sep 17 00:00:00 2001 From: marcsello Date: Mon, 14 Jun 2021 03:34:50 +0200 Subject: [PATCH] Updated stored data --- src/app.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/app.py b/src/app.py index a8cef4d..b921d1c 100644 --- a/src/app.py +++ b/src/app.py @@ -39,19 +39,20 @@ async def on_message(message: IncomingMessage): r = requests.get(f"http://input-service/sample/{msg_json['tag']}") r.raise_for_status() + fields = { + k: float(v) for k, v in msg_json['all_predictions'] + } + fields['_classification_duration'] = float(msg_json['classification_duration']) + point = { 'time': now, 'measurement': 'sturnus', 'tags': { 'device': r.json()['device_id'] }, - 'fields': { - 'probability': float(msg_json['probability']) # This is required because otherwise of the json serialization and de-serialization round values would interpret as ints and influxdb would fail - } + 'fields': fields } - - async with InfluxDBClient(username=config.INFLUXDB_USERNAME, password=config.INFLUXDB_PASSWORD, host=config.INFLUXDB_HOST, port=config.INFLUXDB_PORT, ssl=False, database=config.INFLUXDB_DB) as client: