Fix dead-man check, postgres returns a rowCount of 0, unlike sqlite which returns an undefined object if no rows returned.
This commit is contained in:
parent
92adabcd47
commit
fd746d5523
@ -69,7 +69,6 @@ app.get('/', function(req, res){
|
|||||||
}
|
}
|
||||||
// Loop over elements in rows array, convert ugly UTC times to pretty local times.
|
// Loop over elements in rows array, convert ugly UTC times to pretty local times.
|
||||||
result.rows.forEach(function(row){
|
result.rows.forEach(function(row){
|
||||||
winston.info(row.published_at);
|
|
||||||
row.pubdate = courtsopenUtils.getLocDateFromUTC(row.published_at);
|
row.pubdate = courtsopenUtils.getLocDateFromUTC(row.published_at);
|
||||||
row.pubtime = courtsopenUtils.getLocTimeFromUTC(row.published_at);
|
row.pubtime = courtsopenUtils.getLocTimeFromUTC(row.published_at);
|
||||||
if(row.status.toLowerCase().indexOf('closed') > -1){
|
if(row.status.toLowerCase().indexOf('closed') > -1){
|
||||||
@ -145,7 +144,7 @@ setInterval(function() {
|
|||||||
done();
|
done();
|
||||||
if(err) {
|
if(err) {
|
||||||
return winston.error('error running query', err);
|
return winston.error('error running query', err);
|
||||||
} else if (typeof result == "undefined") {
|
} else if (result.rowCount == 0) {
|
||||||
mailOptions.text = "It's been too long since the last data transmission from device. \n\n";
|
mailOptions.text = "It's been too long since the last data transmission from device. \n\n";
|
||||||
winston.info(mailOptions.text);
|
winston.info(mailOptions.text);
|
||||||
// Don't include any other details for now, will need to change DB query to get details on last message received.
|
// Don't include any other details for now, will need to change DB query to get details on last message received.
|
||||||
@ -153,7 +152,7 @@ setInterval(function() {
|
|||||||
//mailOptions.text = mailOptions.text + 'Published at, ' + courtsopenUtils.getLocDateFromUTC(pubAt) + ' ' + courtsopenUtils.getLocTimeFromUTC(pubAt) + '\n';
|
//mailOptions.text = mailOptions.text + 'Published at, ' + courtsopenUtils.getLocDateFromUTC(pubAt) + ' ' + courtsopenUtils.getLocTimeFromUTC(pubAt) + '\n';
|
||||||
transporter.sendMail(mailOptions, function(error, info){
|
transporter.sendMail(mailOptions, function(error, info){
|
||||||
if(error){
|
if(error){
|
||||||
winston.info(error);
|
winston.error(error);
|
||||||
}else{
|
}else{
|
||||||
winston.info('Message sent: ' + info.response);
|
winston.info('Message sent: ' + info.response);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user