run.py
def Retrieve_hourly_stats_trends():
    """
    Post call to retrieve data across days for a device per user input with hourly stats and trends
    """
    #retrieve the json from the ajax call
    jsonFile = ''
    if request.method == 'POST':
        jsonFile = request.json
        print ("post request")

    #if jsonFile successfully posted..
    if jsonFile != '':
        # check all required arguments are present:
        if not all(arg in jsonFile for arg in ["deviceId","field","startDate","endDate"]):
            print("Missing arguments in post request")
            return json.dumps({"status":"Error", "messages":"Missing arguments"}), 422
        inputDeviceId = jsonFile["deviceId"]
        inputStartDate = jsonFile["startDate"]
        inputEndDate = jsonFile["endDate"]
        inputField = jsonFile["field"]
        print("retreived data: " + str(inputDeviceId) + " | " + str(inputField) + " | " + str(inputStartDate) + " | " + str(inputEndDate))

    #get data for device fields across days
    dataArray = plotdata.Device_data_across_days(inputDeviceId, inputStartDate, inputEndDate)

    #get hourly stats and trends for dataArray
    hourlyData = plotdata.Hourly_stats_trends(dataArray, inputField)

    #create and return the output json
    output = {"dataArray": dataArray, "hourlyData": hourlyData, "deviceId": inputDeviceId, "startdate" : inputStartDate, "enddate" : inputEndDate, "field": inputField}
    return json.dumps(output)

    Post call to retrieve data across days for a device per user input with hourly stats and trends
    
Post call to retrieve data across days for a device per user input with hourly stats and trends
Post call to retrieve data across days for a device per user input with hourly stats and trends
def Retrieve_hourly_stats_trends():
    jsonFile = ''
    if request.method == 'POST':
        jsonFile = request.json
        print ("post request")
    if jsonFile != '':
        if not all(arg in jsonFile for arg in ["deviceId","field","startDate","endDate"]):
            print("Missing arguments in post request")
            return json.dumps({"status":"Error", "messages":"Missing arguments"}), 422
        inputDeviceId = jsonFile["deviceId"]
        inputStartDate = jsonFile["startDate"]
        inputEndDate = jsonFile["endDate"]
        inputField = jsonFile["field"]
        print("retreived data: " + str(inputDeviceId) + " | " + str(inputField) + " | " + str(inputStartDate) + " | " + str(inputEndDate))
    dataArray = plotdata.Device_data_across_days(inputDeviceId, inputStartDate, inputEndDate)
    hourlyData = plotdata.Hourly_stats_trends(dataArray, inputField)
    output = {"dataArray": dataArray, "hourlyData": hourlyData, "deviceId": inputDeviceId, "startdate" : inputStartDate, "enddate" : inputEndDate, "field": inputField}
    return json.dumps(output)
def Retrieve_hourly_stats_trends ( ) : jsonFile = '' if request . method == 'POST' : jsonFile = request . json print ( "post request" ) if jsonFile != '' : if not all ( arg in jsonFile for arg in [ "deviceId" , "field" , "startDate" , "endDate" ] ) : print ( "Missing arguments in post request" ) return json . dumps ( { "status" : "Error" , "messages" : "Missing arguments" } ) , 422 inputDeviceId = jsonFile [ "deviceId" ] inputStartDate = jsonFile [ "startDate" ] inputEndDate = jsonFile [ "endDate" ] inputField = jsonFile [ "field" ] print ( "retreived data: " + str ( inputDeviceId ) + " | " + str ( inputField ) + " | " + str ( inputStartDate ) + " | " + str ( inputEndDate ) ) dataArray = plotdata . Device_data_across_days ( inputDeviceId , inputStartDate , inputEndDate ) hourlyData = plotdata . Hourly_stats_trends ( dataArray , inputField ) output = { "dataArray" : dataArray , "hourlyData" : hourlyData , "deviceId" : inputDeviceId , "startdate" : inputStartDate , "enddate" : inputEndDate , "field" : inputField } return json . dumps ( output )
Post call to retrieve data across days for a device per user input with hourly stats and trends
Post call to retrieve data across days for a device per user input with hourly stats and trends
"""
    Post call to retrieve data across days for a device per user input with hourly stats and trends
    """ #retrieve the json from the ajax call #if jsonFile successfully posted.. # check all required arguments are present: #get data for device fields across days #get hourly stats and trends for dataArray #create and return the output json