Browse Source

🔨 Change Filter in DB query

main
Haris Razis 4 years ago
parent
commit
ff32e505aa
No known key found for this signature in database GPG Key ID: 86A4D290ED03FAB4
  1. 4
      client/src/class/ClientService.ts
  2. 3
      server/src/class/Database.ts

4
client/src/class/ClientService.ts

@ -13,12 +13,12 @@ export class ClientService {
tempService(): void {
setInterval(() => {
this.clientSocket.sendTemp(this.sensor.takeMeasure, 'temperature');
}, 1 * 60000);
}, 5 * 60000);
}
tempTestService(): void {
setInterval(() => {
this.clientSocket.sendTemp(this.sensor.takeTestMeasure, 'temperature');
}, 1 * 60000);
}, 5 * 60000);
}
}

3
server/src/class/Database.ts

@ -49,7 +49,8 @@ export class Database {
}
query(filter: string, timeFrame: string) {
const query = `from(bucket: "${process.env.DB_BUCKET}") |> range(start: -${timeFrame}) |> filter(fn: (r) => r._measurement == "${filter}")`;
const query = `from(bucket: "${process.env.DB_BUCKET}") |> range(start: -${timeFrame}) |> group(columns: ["client"])
|> filter(fn: (r) => r._measurement == "${filter}")`;
const data = this.queryApi
.collectRows(query)

Loading…
Cancel
Save