Пример #1
0
def recent_co2_get_all():
	logging.debug("Received request /recent/co2")
	startTime = time.monotonic()
	try:
		dataArray = []
		co2Array = RecentCO2Model.get_all()
		for tempModel in co2Array:
			dataArray.append(tempModel.to_json())
		elapsedTime = time.monotonic() - startTime
		logging.debug("co2 get all request time: " + str(round(elapsedTime,5))+ " seconds")
		return res(200, data=dataArray, timeUTC=datetime.utcnow())
	except mariadb.Error as e:
		abort(500, str(e))
Пример #2
0
    def get_all():
        # init
        foundPressure = []
        foundHumidities = []
        foundCo2 = []
        foundTemperatures = []

        # Execution (4 connection, could be more efficient but query time is hardly an issue)
        foundPressure = RecentPressureModel.get_all()
        foundHumidities = RecentHumidityModel.get_all()
        foundCo2 = RecentCO2Model.get_all()
        foundTemperatures = RecentTemperatureModel.get_all()

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

        # Clean and return
        return returnObj