diff --git a/server.js b/server.js index eb13f90..aa3d8dc 100644 --- a/server.js +++ b/server.js @@ -40,7 +40,22 @@ pg.connect(conString, function(err, client, done) { if(err) { return console.error('error fetching client from pool', err); } - done(); + + var devIndexQry = + "select al.coreId, max(co.coreName) as coreName, max(co.locationDesc) as locationDesc, mpub.MaxPub, al.status as MaxStatus " + + "from Alerts al " + + "inner join (select coreId, max(published_at) as MaxPub from Alerts group by coreId) mpub on al.coreId = mpub.coreId and al.published_at = mpub.MaxPub " + + "left join Cores co on al.coreId = co.coreId " + + "group by al.coreId, mpub.MaxPub, al.status "; + client.query(devIndexQry, function(err, result) { + //call `done()` to release the client back to the pool + done(); + + if(err) { + return console.error('error running query', err); + } + console.log(result.rows[0].corename); + }); }); db.serialize(function() {