Add most recent status message and published_at date to device index.
This commit is contained in:
		
							parent
							
								
									6f856f006c
								
							
						
					
					
						commit
						c1867cc47f
					
				@ -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 {
 | 
			
		||||
 | 
			
		||||
@ -6,9 +6,9 @@
 | 
			
		||||
        <li>
 | 
			
		||||
            <a href="https://particle.kaplon.us/core/{{this.coreId}}">
 | 
			
		||||
                {{#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}}
 | 
			
		||||
            </a>
 | 
			
		||||
        </li>
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user