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:
jkaplon 2015-12-10 12:54:47 -05:00
parent 92adabcd47
commit fd746d5523

View File

@ -69,7 +69,6 @@ app.get('/', function(req, res){
}
// Loop over elements in rows array, convert ugly UTC times to pretty local times.
result.rows.forEach(function(row){
winston.info(row.published_at);
row.pubdate = courtsopenUtils.getLocDateFromUTC(row.published_at);
row.pubtime = courtsopenUtils.getLocTimeFromUTC(row.published_at);
if(row.status.toLowerCase().indexOf('closed') > -1){
@ -145,7 +144,7 @@ setInterval(function() {
done();
if(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";
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.
@ -153,7 +152,7 @@ setInterval(function() {
//mailOptions.text = mailOptions.text + 'Published at, ' + courtsopenUtils.getLocDateFromUTC(pubAt) + ' ' + courtsopenUtils.getLocTimeFromUTC(pubAt) + '\n';
transporter.sendMail(mailOptions, function(error, info){
if(error){
winston.info(error);
winston.error(error);
}else{
winston.info('Message sent: ' + info.response);
}