Пример #1
0
def historic_pressure_get_oldest():
    logging.debug("Received request /historic/pressures/oldest")
    startTime = time.monotonic()
    try:
        returnValue = HistoricPressureModel.get_oldest()
        if returnValue is None:
            abort(404)
        data = returnValue.to_json()
        elapsedTime = time.monotonic() - startTime
        logging.debug("pressure get oldest request time: " +
                      str(round(elapsedTime, 5)) + " seconds")
        return res(200, data=data, timeUTC=datetime.utcnow())
    except mariadb.Error as e:
        abort(500, str(e))
Пример #2
0
	def get_oldest():
		# init
		foundPressure = None
		foundHumidities = None
		foundCo2 = None
		foundTemperatures = None

		# Execution (4 connection, could be more efficient but query time is hardly an issue)
		foundPressure = HistoricPressureModel.get_oldest()
		foundHumidities = HistoricHumidityModel.get_oldest()
		foundCo2 = HistoricCO2Model.get_oldest()
		foundTemperatures = HistoricTemperatureModel.get_oldest()

		# Build object
		returnObj = HistoricSensorModel(
			foundPressure, foundHumidities, foundCo2, foundTemperatures)

		# Clean and return
		return returnObj