Updating alert threshold to four days

This commit is contained in:
JayWll 2020-04-17 17:29:27 -06:00
parent fc2ad0014c
commit 9c30d07271

View File

@ -48,10 +48,10 @@ app.get('/newreading', (req, res) => {
// If the low moisture flag is set but an alert has not yet been sent, determine if an alert is necessarry // If the low moisture flag is set but an alert has not yet been sent, determine if an alert is necessarry
if (result.find(o => o.dataValues.key === 'low').dataValues.value !== '0' && result.find(o => o.dataValues.key === 'alert').dataValues.value === '0') { if (result.find(o => o.dataValues.key === 'low').dataValues.value !== '0' && result.find(o => o.dataValues.key === 'alert').dataValues.value === '0') {
const lowtriggered = new Date().getTime() - new Date(result.find(o => o.dataValues.key === 'low').dataValues.value).getTime() const lowtriggered = new Date().getTime() - new Date(result.find(o => o.dataValues.key === 'low').dataValues.value).getTime()
const fivedays = 5 * 24 * 60 * 60 * 1000 const fourdays = 4 * 24 * 60 * 60 * 1000
// If the first low reading was more than 5 days ago, send an alert // If the first low reading was more than 5 days ago, send an alert
if (lowtriggered > fivedays) { if (lowtriggered > fourdays) {
// Pick a random message from the array below // Pick a random message from the array below
const tweet = [ const tweet = [
'I\'m getting pretty thirsty over here, @JayWll', 'I\'m getting pretty thirsty over here, @JayWll',