def get_current_supply(): """ Returns current water supply (previously saved in "percent" value). :return: Percent value (0-100) of water supply. Default: 0. """ results = db.query('SELECT * FROM water_supply ORDER BY date_time DESC LIMIT 1', one=True) if results: return results["level"] return 0
def get_last_month_avg(): results = db.query('SELECT *, AVG(level) AS average FROM moisture_level ' \ 'GROUP BY date_time ORDER BY date_time DESC LIMIT 720') return results
def api_weather(): weather_results = db.query('SELECT * FROM weather WHERE date_time >= date(\'now\', \'start of day\') ORDER BY date_time ASC LIMIT 5', db=app_get_db()) return Response(response=json.dumps(weather_results), status=200, mimetype="application/json")