From f803ddc135cb69de63cfe98dedce6fb6df11e53d Mon Sep 17 00:00:00 2001 From: Haris Razis Date: Mon, 23 Nov 2020 17:15:15 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9E=95=20Add=20formatting=20to=20/measuremen?= =?UTF-8?q?ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/class/Database.ts | 6 +++++- server/src/routes/Routes.ts | 18 +++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/server/src/class/Database.ts b/server/src/class/Database.ts index 0165138..bcd8950 100644 --- a/server/src/class/Database.ts +++ b/server/src/class/Database.ts @@ -68,7 +68,11 @@ export class Database { let formatedData: Array<{}> = []; rawData.forEach((element: any) => { - formatedData.push({ time: element._time, value: element._value }); + formatedData.push({ + client: element.client, + time: element._time, + value: element._value, + }); }); return formatedData; diff --git a/server/src/routes/Routes.ts b/server/src/routes/Routes.ts index 5621bb4..1c1bc15 100644 --- a/server/src/routes/Routes.ts +++ b/server/src/routes/Routes.ts @@ -1,5 +1,4 @@ import * as express from 'express'; -import { Database } from '../class/Database'; import { Service } from '../class/Service'; export class Routes { @@ -39,17 +38,14 @@ export class Routes { private measurements(): void { this.app.get('/measurements', async (req, res) => { - req.on('data', async (data) => { - const { filter, timeFrame } = JSON.parse(data); - const points = await this.service.database.query('temperature', '5m'); + const points = await this.service.database.query('temperature', '1h'); - res.header('Content-Type', 'application/json'); - if (points) { - res.send(JSON.stringify(points)); - } else { - res.send(JSON.stringify({})); - } - }); + res.header('Content-Type', 'application/json'); + if (points) { + res.send(JSON.stringify(points)); + } else { + res.send(JSON.stringify({})); + } }); }