I am trying to make a graph for the availability of machines.
For example, I want to know that at 4pm, 10 machines were used, and at 7pm, nothing was used.
To do so, I started sending points to InfluxDB, like this:
fetchMachines(token).then((machines) => {
let writeClient = client.getWriteApi(org, bucket, 'ns');
for (let machine of machines) {
let point = new Point('machines_a_laver')
.tag('machine_id', machine.number.toString() + ' ' + machine.room)
.stringField('status', machine.state);
writeClient.writePoint(point);
}
writeClient.flush().then(() => {
console.log('FINISHED')
});
});
Status can be ACTIVATED or DEACTIVATED.
How can I write a query that:
- take the last status of each machine
ACTIVATEDorDEACTIVATED. - convert this status to 0 or 1.
- sum everything to get the total number of machines used.
Thank you.