python/foglamp/services/core/api/browser.py
async def asset_counts(request):
    """ Browse all the assets for which we have recorded readings and
    return a readings count.

    Returns:
           json result on basis of SELECT asset_code, count(*) FROM readings GROUP BY asset_code;

    :Example:
            curl -sX GET http://localhost:8081/foglamp/asset
    """
    payload = PayloadBuilder().AGGREGATE(["count", "*"]).ALIAS("aggregate", ("*", "count", "count")) \
        .GROUP_BY("asset_code").payload()

    results = {}
    try:
        _readings = connect.get_readings_async()
        results = await _readings.query(payload)
        response = results['rows']
        asset_json = [{"count": r['count'], "assetCode": r['asset_code']} for r in response]
    except KeyError:
        raise web.HTTPBadRequest(reason=results['message'])
    else:
        return web.json_response(asset_json)
 Browse all the assets for which we have recorded readings and
    return a readings count.

    Returns:
           json result on basis of SELECT asset_code, count(*) FROM readings GROUP BY asset_code;

    :Example:
            curl -sX GET http://localhost:8081/foglamp/asset
    
Browse all the assets for which we have recorded readings and
return a readings count.


Browse all the assets for which we have recorded readings and return a readings count .
async def asset_counts(request):
    payload = PayloadBuilder().AGGREGATE(["count", "*"]).ALIAS("aggregate", ("*", "count", "count")) \
        .GROUP_BY("asset_code").payload()
    results = {}
    try:
        _readings = connect.get_readings_async()
        results = await _readings.query(payload)
        response = results['rows']
        asset_json = [{"count": r['count'], "assetCode": r['asset_code']} for r in response]
    except KeyError:
        raise web.HTTPBadRequest(reason=results['message'])
    else:
        return web.json_response(asset_json)
async def asset_counts ( request ) : payload = PayloadBuilder ( ) . AGGREGATE ( [ "count" , "*" ] ) . ALIAS ( "aggregate" , ( "*" , "count" , "count" ) ) . GROUP_BY ( "asset_code" ) . payload ( ) results = { } try : _readings = connect . get_readings_async ( ) results = await _readings . query ( payload ) response = results [ 'rows' ] asset_json = [ { "count" : r [ 'count' ] , "assetCode" : r [ 'asset_code' ] } for r in response ] except KeyError : raise web . HTTPBadRequest ( reason = results [ 'message' ] ) else : return web . json_response ( asset_json )
Browse all the assets for which we have recorded readings and
return a readings count.
Browse all the assets for which we have recorded readings and return a readings count .
""" Browse all the assets for which we have recorded readings and
    return a readings count.

    Returns:
           json result on basis of SELECT asset_code, count(*) FROM readings GROUP BY asset_code;

    :Example:
            curl -sX GET http://localhost:8081/foglamp/asset
    """
request
Example
None