This commit is contained in:
2024-07-16 10:30:09 -04:00
parent 853529b871
commit 007dca7bfb
2 changed files with 64 additions and 38 deletions

View File

@@ -14,11 +14,8 @@ router = APIRouter(
def Average(lst):
return sum(lst) / len(lst)
@router.route("/update", methods=["GET"])
def update_auto():
def update_auto_customers():
today_temp = session\
@@ -33,8 +30,34 @@ def update_auto():
.limit(25)
for f in auto_customers:
pass
# figure out how much temperature effects oil
if today_temp >= 60:
use_day = 1
elif 40 >= today_temp >= 59:
use_day = 3
elif 30 >= today_temp >= 39:
use_day = 5
elif 0 >= today_temp >= 29:
use_day = 7
elif -20 >= today_temp >= -1:
use_day = 10
else:
use_day = 0
# times temp factory by house factor
gallon_use_today = f.house_factor * use_day
# get estimated gallons left
get_gallons_left = f.estimated_gallons_left_prev_day - gallon_use_today
# get previous day gallons left
f.estimated_gallons_left_prev_day = f.estimated_gallons_left + gallon_use_today
f.estimated_gallons_left = get_gallons_left
session.add(f)
session.commit()
return ({"ok": True}), 200
@@ -52,13 +75,13 @@ def update_temp():
observation = mgr.weather_at_place('Worcester, US')
w = observation.weather
temp_dict_kelvin = w.temperature() # a dict in Kelvin units (default when no temperature units provided)
temp_dict_kelvin['temp_min']
temp_dict_kelvin['temp_max']
temp_dict_fahrenheit = w.temperature() # a dict in Kelvin units (default when no temperature units provided)
temp_dict_fahrenheit['temp_min']
temp_dict_fahrenheit['temp_max']
temp_dict_fahrenheit = w.temperature('fahrenheit')
low_temp = temp_dict_kelvin['temp_min']
high_temp = temp_dict_kelvin['temp_max']
low_temp = temp_dict_fahrenheit['temp_min']
high_temp = temp_dict_fahrenheit['temp_max']
temps.append(temp_dict_fahrenheit['temp_max'])
temps.append(temp_dict_fahrenheit['temp_min'])
@@ -66,7 +89,6 @@ def update_temp():
rounded_temp = round(get_avg)
dday = (65 - ((low_temp + high_temp) /2))
add_new_temp = Auto_Temp(
temp = temp_dict_fahrenheit['temp'],
@@ -83,25 +105,7 @@ def update_temp():
return ({"ok": True}), 200
@router.get("/today")
def auto_today():
today_auto = session.query().filter().first()
return ({"ok": True}), 200
def Average(lst):
return sum(lst) / len(lst)
@router.get("/week")
def auto_this_week():
print("here")
return ({"ok": True}), 200
@router.get("/all")
def all_auto():
return ({"ok": True}), 200
@router.get("/completed")
def completed_auto():
return ({"ok": True}), 200