Exemple #1
0
def historic_humidity_get_newest():
	logging.debug("Received request /historic/humidities/newest")
	startTime = time.monotonic()
	try:
		returnValue = HistoricHumidityModel.get_newest()
		if returnValue is None:
			abort(404)
		data = returnValue.to_json()
		elapsedTime = time.monotonic() - startTime
		logging.debug("humidity get newest request time: " + str(round(elapsedTime,5))+ " seconds")
		return res(200, data=data, timeUTC=datetime.utcnow())
	except mariadb.Error as e:
		logging.exception(e)
		abort(500, str(e))
Exemple #2
0
	def get_newest():
		# 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_newest()
		foundHumidities = HistoricHumidityModel.get_newest()
		foundCo2 = HistoricCO2Model.get_newest()
		foundTemperatures = HistoricTemperatureModel.get_newest()

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

		# Clean and return
		return returnObj