diff --git a/server.js b/server.js index fc6eb18..26398b6 100644 --- a/server.js +++ b/server.js @@ -59,7 +59,12 @@ app.set('views', __dirname + '/views'); app.get('/', function(req, res){ var d = new Date(); console.log("GET /, " + JSON.stringify(d, 4)); - db.all("SELECT coreId, coreName, locationDesc FROM Alerts GROUP BY coreId, coreName, locationDesc;", function(err, rows){ + var devIndexQry = + "select coreId, coreName, locationDesc, max(published_at) as MaxPub, max(status) as MaxStatus " + + "from Alerts otbl " + + "where published_at = (select max(published_at) from Alerts where coreId = otbl.coreId) " + + "group by coreId, coreName, locationDesc;"; + db.all(devIndexQry, function(err, rows){ if(err !== null) { console.log(err); } else { diff --git a/views/index.hbs b/views/index.hbs index aa80fbf..dc50c61 100644 --- a/views/index.hbs +++ b/views/index.hbs @@ -6,9 +6,9 @@
  • {{#if this.coreName}} - {{this.coreName}}, {{this.locationDesc}} + {{this.coreName}}, {{this.locationDesc}}, {{this.MaxPub}}, {{this.MaxStatus}} {{else}} - {{this.coreId}}, {{this.locationDesc}} + {{this.coreId}}, {{this.locationDesc}}, {{this.MaxPub}}, {{this.MaxStatus}} {{/if}}