#NEWLINE# @ ajax_request #NEWLINE# @ login_required #NEWLINE# @ has_perm ( 'requires_viewer' ) #NEWLINE# def get_timeseries( request ) : #NEWLINE# #INDENT# 'Return all time series data for a building, grouped by meter.\n\n    Expected GET params:\n\n    meter_id: int, unique identifier for the meter.\n    offset: int, the offset from the most recent meter data to begin showing.\n    num: int, the number of results to show.\n    ' #NEWLINE# meter_id = request . GET . get ( 'meter_id' , '' ) #NEWLINE# offset = int ( request . GET . get ( 'offset' , 0 ) ) #NEWLINE# num = int ( request . GET . get ( 'num' , 12 ) ) #NEWLINE# if ( not meter_id ) : #NEWLINE# #INDENT# return { #NEWLINE# #INDENT# 'status' : 'error' , #NEWLINE# 'message' : 'No meter id specified' , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# result = { #NEWLINE# #INDENT# 'status' : 'success' , #NEWLINE# 'meter_id' : result , #NEWLINE# 'timeseries' : [ ] , #NEWLINE# #UNINDENT# } #NEWLINE# paginated_ts = TimeSeries . objects . filter ( meter_id = meter_id ) [ offset : ( offset + num ) ] #NEWLINE# for ts in paginated_ts : #NEWLINE# #INDENT# t = obj_to_dict ( ts ) #NEWLINE# result [ 'timeseries' ] . append ( t ) #NEWLINE# #UNINDENT# return result