made changes in tanks controller

master
varun 3 years ago
parent 27bd372904
commit ce802ed7bd

@ -145,27 +145,25 @@ exports.updateTanklevels = async (req, reply) => {
try {
const customerId = req.params.customerId;
const tank = await Tank.find({customerId});
clearInterval(intervalTimer);
for (var i=0; i < tank.length; i++) {
const tankname = tank[i].tankName
const capacity = tank[i].capacity
//console.log(capacity)
const capacity = (tank[i].capacity).replace(/,/g, "")
console.log(capacity)
let Number = capacity-100 //Math.floor(Math.random() * capacity)
//console.log(Number)
setInterval(async function () {
// const randomNumber = Math.floor(Math.random() * capacity)
//const randomNumber = Math.floor(Math.random() * (5500 - 1000) + 1000);
//const randomNumber = Math.floor(Math.random() * (5500 - 1000) + 1000);E
// console.log(randomNumber)
//console.log(tankname)
const randomNumber = Math.floor(Number/1.5)
console.log(randomNumber)
await Tank.findOneAndUpdate({ customerId: customerId, tankName: tankname },{ $set: { waterlevel: randomNumber } }, { upsert: true, new: true });
const data = await Tank.findOneAndUpdate({ customerId: customerId, tankName: tankname }, { $set: { waterlevel: randomNumber } });
Number = randomNumber
//return Number
// return Number
}, 2000);
}
@ -182,7 +180,6 @@ exports.updateTanklevels = async (req, reply) => {
exports.getTanklevels = async (req, reply) => {
try {
const customerId = req.params.customerId;
// await tanksController.updateTanklevels(req)
const updated_data = await Tank.find({ customerId: customerId });
@ -198,4 +195,4 @@ exports.getTanklevels = async (req, reply) => {
throw boom.boomify(err);
}
};
Loading…
Cancel
Save