run.py
def Retrieve_device_stats():
    """
    Post call to retrieve device stats for devices
    """

    #retrieve the json from the ajax call
    json_file = ''
    if request.method == 'POST':
        json_file = request.json
        print ("post request")

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

    #split deviceIds from input
    deviceIds = inputDeviceIds.split(",")

    #get data for devices across days
    dataArray = plotdata.Devices_data_across_days(deviceIds, inputStartDate, inputEndDate)

    #get plot data to compare devices
    plotdataArray = plotdata.Devices_field_data(dataArray, deviceIds, inputField)

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

    Post call to retrieve device stats for devices
    
Post call to retrieve device stats for devices
Post call to retrieve device stats for devices
def Retrieve_device_stats():
    json_file = ''
    if request.method == 'POST':
        json_file = request.json
        print ("post request")
    if json_file != '':
        if not all(arg in json_file for arg in ["deviceIds","field","startDate","endDate"]):
            print("Missing arguments in post request")
            return json.dumps({"status":"Error", "messages":"Missing arguments"}), 422
        inputDeviceIds = json_file["deviceIds"]
        inputStartDate = json_file["startDate"]
        inputEndDate = json_file["endDate"]
        inputField = json_file["field"]
        print("retreived data: " + str(inputDeviceIds) + " | " + str(inputStartDate) + " | " + str(inputEndDate) + " | " + str(inputField))
    deviceIds = inputDeviceIds.split(",")
    dataArray = plotdata.Devices_data_across_days(deviceIds, inputStartDate, inputEndDate)
    plotdataArray = plotdata.Devices_field_data(dataArray, deviceIds, inputField)
    output = {"dataArray": dataArray, "deviceIds": deviceIds, "plotdata": plotdataArray, "startdate": inputStartDate, "enddate" : inputEndDate, "field": inputField}
    return json.dumps(output)
def Retrieve_device_stats ( ) : json_file = '' if request . method == 'POST' : json_file = request . json print ( "post request" ) if json_file != '' : if not all ( arg in json_file for arg in [ "deviceIds" , "field" , "startDate" , "endDate" ] ) : print ( "Missing arguments in post request" ) return json . dumps ( { "status" : "Error" , "messages" : "Missing arguments" } ) , 422 inputDeviceIds = json_file [ "deviceIds" ] inputStartDate = json_file [ "startDate" ] inputEndDate = json_file [ "endDate" ] inputField = json_file [ "field" ] print ( "retreived data: " + str ( inputDeviceIds ) + " | " + str ( inputStartDate ) + " | " + str ( inputEndDate ) + " | " + str ( inputField ) ) deviceIds = inputDeviceIds . split ( "," ) dataArray = plotdata . Devices_data_across_days ( deviceIds , inputStartDate , inputEndDate ) plotdataArray = plotdata . Devices_field_data ( dataArray , deviceIds , inputField ) output = { "dataArray" : dataArray , "deviceIds" : deviceIds , "plotdata" : plotdataArray , "startdate" : inputStartDate , "enddate" : inputEndDate , "field" : inputField } return json . dumps ( output )
Post call to retrieve device stats for devices
Post call to retrieve device stats for devices
"""
    Post call to retrieve device stats for devices
    """ #retrieve the json from the ajax call #if json_file successfully posted.. # check all required arguments are present: #split deviceIds from input #get data for devices across days #get plot data to compare devices #create and return the output json