def historic_temperatures_reset_in_range(): logging.debug("Received request /historic/temperatures/reset/range") startTime = time.monotonic() try: # Requires a simple pw pw = req.args.get("pw") logging.debug("pw arg is: " + str(pw)) if pw != "A7G2V9": abort(403) start = req.args.get('start') if start is None: start = '2020-01-01T00:00:00' logging.debug("Start arg is: " + str(start)) end = req.args.get('end') if end is None: end = datetime.utcnow() logging.debug("End arg is: " + str(end)) HistoricTemperatureModel.delete_by_range(start, end) elapsedTime = time.monotonic() - startTime logging.debug("temperature reset in range request time: " + str(round(elapsedTime, 5)) + " seconds") return res(204, timeUTC=datetime.utcnow()) except mariadb.Error as e: abort(500, str(e))
def delete_by_range(start, end): # Init returnValue = True # Execution HistoricPressureModel.delete_by_range(start, end) HistoricHumidityModel.delete_by_range(start, end) HistoricCO2Model.delete_by_range(start, end) HistoricTemperatureModel.delete_by_range(start, end) # Clean and return return returnValue