Change identing etc based on trvial review comments
@@ -11,13 +11,13 @@ Supports a number of REST API:
http://<address>/foglamp/asset
- Return a summary count of all asset readings
- http://<address>/foglamp/asset/{asset}
+ http://<address>/foglamp/asset/{asset_code}
- Return a set of asset readings for the given asset
- http://<address>/foglamp/asset/{asset}/{reading}
+ http://<address>/foglamp/asset/{asset_code}/{reading}
- Return a set of sensor readings for the specified asset and sensor
- http://<address>/foglamp/asset/{asset}/{reading}/summary
+ http://<address>/foglamp/asset/{asset_code}/{reading}/summary
- Return a summary (min, max and average) for the specified asset and sensor
- http://<address>/foglamp/asset/{asset}/{reading}/series
+ http://<address>/foglamp/asset/{asset_code}/{reading}/series
- Return a time series (min, max and average) for the specified asset and
sensor averages over seconds, minutes or hours. The selection of seconds, minutes
or hours is done via the group query parameter
@@ -253,12 +253,11 @@ async def asset_averages(request):
if 'group' in request.query:
if request.query['group'] == 'seconds':
ts_restraint = 'YYYY-MM-DD HH24:MI:SS'
- if request.query['group'] == 'minutes':
+ elif request.query['group'] == 'minutes':
ts_restraint = 'YYYY-MM-DD HH24:MI'
- if request.query['group'] == 'hours':
+ elif request.query['group'] == 'hours':
ts_restraint = 'YYYY-MM-DD HH24'
-
query = 'select to_char(user_ts, \'{2}\'), min(reading->>\'{1}\'), max(reading->>\'{1}\'), avg((reading->>\'{1}\')::float) from readings where asset_code = \'{0}\''.format(asset_code, reading, ts_restraint)
query += _where_clause(request)
