def update_device_hourly_measurements(): clarity_api = ClarityApi() devices_codes = list(mongo.db.devices.find({}, {"code": 1, "_id": 0})) average = 'hour' for device_code in devices_codes: code = device_code['code'] clarity_api.update_device_hourly_measurements(code, average) return jsonify({'response': 'all new hourly measurements saved'}), 200
def get_and_save_hourly_measurements(): devices_codes = list(mongo.db.devices.find({}, {"code": 1, "_id": 0})) clarity_api = ClarityApi() average = 'hour' for code in devices_codes: clarity_api.save_clarity_device_hourly_measurements_v2( average, code['code']) return jsonify({'response': 'all hourly measurements saved'}), 200
def get_and_save_device_measurements(): if request.method == 'GET': code = request.args.get('code') startTime = request.args.get('startTime') average = request.args.get('average') limit = request.args.get('limit') clarity_api = ClarityApi() if average == 'hour': clarity_api.save_clarity_device_hourly_measurements( average, code, startTime, limit) return jsonify({'response': 'device measurements saved'}), 200 elif average == 'day': clarity_api.save_clarity_device_daily_measurements( average, code, startTime, limit) return jsonify({'response': 'device daily measurements saved'}), 200
def get_devices(): if request.method == 'GET': clarity_api = ClarityApi() devices, status_code = clarity_api.get_all_devices() return jsonify(devices), status_code
def get_and_save_devices(): if request.method == 'GET': clarity_api = ClarityApi() clarity_api.save_clarity_devices() return jsonify({'response': 'devices saved'}), 200
def update_raw_measurements(): devices_codes = list(mongo.db.devices.find({}, {"code": 1, "_id": 0})) clarity_api = ClarityApi() for code in devices_codes: clarity_api.update_clarity_data(code) return jsonify({'response': 'all new raw measurements saved'}), 200
def get_and_save_raw_measurements(): devices_codes = list(mongo.db.devices.find({}, {"code": 1, "_id": 0})) clarity_api = ClarityApi() for code in devices_codes: clarity_api.save_clarity_raw_device_measurements(code) return jsonify({'response': 'all raw measurements saved'}), 200