This is for getting tank levels

master
varun 1 year ago
parent bded7a1e59
commit 3af5209675

@ -2377,14 +2377,10 @@ exports.update_auto_percentage = async (req, reply) => {
//storing water level for every 15 minutes //storing water level for every 15 minutes
const getFormattedISTTime = () => {
return moment().tz('Asia/Kolkata').format('DD-MM-YYYY hh:mm:ss A');
};
const storeWaterLevels = async () => { const storeWaterLevels = async () => {
try { try {
const tanks = await Tank.find({}); const tanks = await Tank.find({});
const currentTime = getFormattedISTTime(); const currentTime = new Date().toISOString();
const waterLevelRecords = tanks.map(tank => ({ const waterLevelRecords = tanks.map(tank => ({
customerId: tank.customerId, customerId: tank.customerId,
@ -2401,4 +2397,4 @@ const storeWaterLevels = async () => {
} }
}; };
setInterval(storeWaterLevels, 15 * 60 * 1000); setInterval(storeWaterLevels, 15 * 60 * 1000); // Run every 15 minutes

@ -76,7 +76,7 @@ const tanksSchema = new mongoose.Schema({
manual_threshold_time:{type: String, default: null}, manual_threshold_time:{type: String, default: null},
threshold_type:{type: String, default: "percentage"}, threshold_type:{type: String, default: "percentage"},
startTime:{type: String,default:null}, startTime:{type: String,default:null},
start_instance_id:{type:String,default:null},
stopTime:{type: String,default:null} stopTime:{type: String,default:null}
} }
], ],

Loading…
Cancel
Save