small fixes

This commit is contained in:
2024-12-23 18:10:43 -05:00
parent 8569430468
commit 4a2ec2418c
4 changed files with 8 additions and 6 deletions

View File

@@ -39,13 +39,14 @@ async def update_auto(autoid: int, request: Request):
new_home_factor = calc_home_factor(gallons_put_in_home = gallons_put_in_home, new_home_factor = calc_home_factor(gallons_put_in_home = gallons_put_in_home,
current_house_factor=customer_home_factor) current_house_factor=customer_home_factor)
gallons_left_buffer = get_auto_delivery.tank_size - 30
get_auto_delivery.house_factor = new_home_factor get_auto_delivery.house_factor = new_home_factor
get_auto_delivery.tank_height = 'Full' get_auto_delivery.tank_height = 'Full'
get_auto_delivery.last_fill = date.today() get_auto_delivery.last_fill = date.today()
get_auto_delivery.estimated_gallons_left = 240 get_auto_delivery.estimated_gallons_left = gallons_left_buffer
get_auto_delivery.estimated_gallons_left_prev_day = 240 get_auto_delivery.estimated_gallons_left_prev_day = gallons_left_buffer
get_auto_delivery.auto_status = 1 get_auto_delivery.auto_status = 1
get_auto_delivery.days_since_last_fill = 0 get_auto_delivery.days_since_last_fill = 0

View File

@@ -22,7 +22,7 @@ def get_delivery_customers():
automatics = ( automatics = (
session.query(Auto_Delivery) session.query(Auto_Delivery)
.filter(Auto_Delivery.auto_status == 1) .filter(Auto_Delivery.auto_status == 1)
.order_by(Auto_Delivery.estimated_gallons_left.desc()) .order_by(Auto_Delivery.estimated_gallons_left.asc())
.all() .all()
) )

View File

@@ -98,7 +98,7 @@ def update_auto_customers():
f.estimated_gallons_left = get_gallons_left f.estimated_gallons_left = get_gallons_left
f.last_updated = date.today()
session.add(create_new_update) session.add(create_new_update)
session.add(f) session.add(f)
session.commit() session.commit()

View File

@@ -21,5 +21,6 @@ def calc_home_factor(gallons_put_in_home, current_house_factor):
customer_home_factor = Decimal(current_house_factor) - Decimal(.75) customer_home_factor = Decimal(current_house_factor) - Decimal(.75)
else: else:
customer_home_factor = Decimal(current_house_factor) customer_home_factor = Decimal(current_house_factor)
if customer_home_factor <= 0:
customer_home_factor = Decimal(.25)
return customer_home_factor return customer_home_factor