python/foglamp/services/core/api/browser.py
async def asset_summary(request):
    """ Browse all the assets for which we have recorded readings and
    return a summary for a particular sensor. The values that are
    returned are the min, max and average values of the sensor.

    The readings summarised can also be time limited by use of the query
    parameter seconds=sss. This defines a number of seconds that the reading
    must have been processed in. Older readings than this will not be summarised.

    The readings summarised can also be time limited by use of the query
    parameter minutes=mmm. This defines a number of minutes that the reading
    must have been processed in. Older readings than this will not be summarised.

    The readings summarised can also be time limited by use of the query
    parameter hours=hh. This defines a number of hours that the reading
    must have been processed in. Older readings than this will not be summarised.

    Only one of hour, minutes or seconds should be supplied

    Returns:
           json result on basis of SELECT MIN(reading->>'reading'), MAX(reading->>'reading'), AVG((reading->>'reading')::float) FROM readings WHERE asset_code = 'asset_code';

    :Example:
            curl -sX GET http://localhost:8081/foglamp/asset/fogbench_humidity/temperature/summary
    """
    asset_code = request.match_info.get('asset_code', '')
    reading = request.match_info.get('reading', '')
    _aggregate = PayloadBuilder().AGGREGATE(["min", ["reading", reading]], ["max", ["reading", reading]],
                                            ["avg", ["reading", reading]]) \
        .ALIAS('aggregate', ('reading', 'min', 'min'), ('reading', 'max', 'max'),
               ('reading', 'avg', 'average')).chain_payload()
    _where = PayloadBuilder(_aggregate).WHERE(["asset_code", "=", asset_code]).chain_payload()
    _and_where = where_clause(request, _where)
    payload = PayloadBuilder(_and_where).payload()

    results = {}
    try:
        _readings = connect.get_readings_async()
        results = await _readings.query(payload)
        # for aggregates, so there can only ever be one row
        response = results['rows'][0]
    except KeyError:
        raise web.HTTPBadRequest(reason=results['message'])
    else:
        return web.json_response({reading: response})
 Browse all the assets for which we have recorded readings and
    return a summary for a particular sensor. The values that are
    returned are the min, max and average values of the sensor.

    The readings summarised can also be time limited by use of the query
    parameter seconds=sss. This defines a number of seconds that the reading
    must have been processed in. Older readings than this will not be summarised.

    The readings summarised can also be time limited by use of the query
    parameter minutes=mmm. This defines a number of minutes that the reading
    must have been processed in. Older readings than this will not be summarised.

    The readings summarised can also be time limited by use of the query
    parameter hours=hh. This defines a number of hours that the reading
    must have been processed in. Older readings than this will not be summarised.

    Only one of hour, minutes or seconds should be supplied

    Returns:
           json result on basis of SELECT MIN(reading->>'reading'), MAX(reading->>'reading'), AVG((reading->>'reading')::float) FROM readings WHERE asset_code = 'asset_code';

    :Example:
            curl -sX GET http://localhost:8081/foglamp/asset/fogbench_humidity/temperature/summary
    
Browse all the assets for which we have recorded readings and
return a summary for a particular sensor. The values that are
returned are the min, max and average values of the sensor.

The readings summarised can also be time limited by use of the query
parameter seconds=sss. This defines a number of seconds that the reading
must have been processed in. Older readings than this will not be summarised.

The readings summarised can also be time limited by use of the query
parameter minutes=mmm. This defines a number of minutes that the reading
must have been processed in. Older readings than this will not be summarised.

The readings summarised can also be time limited by use of the query
parameter hours=hh. This defines a number of hours that the reading
must have been processed in. Older readings than this will not be summarised.

Only one of hour, minutes or seconds should be supplied


Browse all the assets for which we have recorded readings and return a summary for a particular sensor . The values that are returned are the min max and average values of the sensor . The readings summarised can also be time limited by use of the query parameter seconds = sss . This defines a number of seconds that the reading must have been processed in . Older readings than this will not be summarised . The readings summarised can also be time limited by use of the query parameter minutes = mmm . This defines a number of minutes that the reading must have been processed in . Older readings than this will not be summarised . The readings summarised can also be time limited by use of the query parameter hours = hh . This defines a number of hours that the reading must have been processed in . Older readings than this will not be summarised . Only one of hour minutes or seconds should be supplied
async def asset_summary(request):
    asset_code = request.match_info.get('asset_code', '')
    reading = request.match_info.get('reading', '')
    _aggregate = PayloadBuilder().AGGREGATE(["min", ["reading", reading]], ["max", ["reading", reading]],
                                            ["avg", ["reading", reading]]) \
        .ALIAS('aggregate', ('reading', 'min', 'min'), ('reading', 'max', 'max'),
               ('reading', 'avg', 'average')).chain_payload()
    _where = PayloadBuilder(_aggregate).WHERE(["asset_code", "=", asset_code]).chain_payload()
    _and_where = where_clause(request, _where)
    payload = PayloadBuilder(_and_where).payload()
    results = {}
    try:
        _readings = connect.get_readings_async()
        results = await _readings.query(payload)
        response = results['rows'][0]
    except KeyError:
        raise web.HTTPBadRequest(reason=results['message'])
    else:
        return web.json_response({reading: response})
async def asset_summary ( request ) : asset_code = request . match_info . get ( 'asset_code' , '' ) reading = request . match_info . get ( 'reading' , '' ) _aggregate = PayloadBuilder ( ) . AGGREGATE ( [ "min" , [ "reading" , reading ] ] , [ "max" , [ "reading" , reading ] ] , [ "avg" , [ "reading" , reading ] ] ) . ALIAS ( 'aggregate' , ( 'reading' , 'min' , 'min' ) , ( 'reading' , 'max' , 'max' ) , ( 'reading' , 'avg' , 'average' ) ) . chain_payload ( ) _where = PayloadBuilder ( _aggregate ) . WHERE ( [ "asset_code" , "=" , asset_code ] ) . chain_payload ( ) _and_where = where_clause ( request , _where ) payload = PayloadBuilder ( _and_where ) . payload ( ) results = { } try : _readings = connect . get_readings_async ( ) results = await _readings . query ( payload ) response = results [ 'rows' ] [ 0 ] except KeyError : raise web . HTTPBadRequest ( reason = results [ 'message' ] ) else : return web . json_response ( { reading : response } )
Browse all the assets for which we have recorded readings and
return a summary for a particular sensor.
Browse all the assets for which we have recorded readings and return a summary for a particular sensor .
""" Browse all the assets for which we have recorded readings and
    return a summary for a particular sensor. The values that are
    returned are the min, max and average values of the sensor.

    The readings summarised can also be time limited by use of the query
    parameter seconds=sss. This defines a number of seconds that the reading
    must have been processed in. Older readings than this will not be summarised.

    The readings summarised can also be time limited by use of the query
    parameter minutes=mmm. This defines a number of minutes that the reading
    must have been processed in. Older readings than this will not be summarised.

    The readings summarised can also be time limited by use of the query
    parameter hours=hh. This defines a number of hours that the reading
    must have been processed in. Older readings than this will not be summarised.

    Only one of hour, minutes or seconds should be supplied

    Returns:
           json result on basis of SELECT MIN(reading->>'reading'), MAX(reading->>'reading'), AVG((reading->>'reading')::float) FROM readings WHERE asset_code = 'asset_code';

    :Example:
            curl -sX GET http://localhost:8081/foglamp/asset/fogbench_humidity/temperature/summary
    """ # for aggregates, so there can only ever be one row
request
Example
None