diff --git a/app/routers/confirm.py b/app/routers/confirm.py index 88ee627..abd5f95 100644 --- a/app/routers/confirm.py +++ b/app/routers/confirm.py @@ -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, 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.tank_height = 'Full' get_auto_delivery.last_fill = date.today() - get_auto_delivery.estimated_gallons_left = 240 - get_auto_delivery.estimated_gallons_left_prev_day = 240 + get_auto_delivery.estimated_gallons_left = gallons_left_buffer + get_auto_delivery.estimated_gallons_left_prev_day = gallons_left_buffer get_auto_delivery.auto_status = 1 get_auto_delivery.days_since_last_fill = 0 diff --git a/app/routers/delivery.py b/app/routers/delivery.py index 0435513..665f4db 100644 --- a/app/routers/delivery.py +++ b/app/routers/delivery.py @@ -22,7 +22,7 @@ def get_delivery_customers(): automatics = ( session.query(Auto_Delivery) .filter(Auto_Delivery.auto_status == 1) - .order_by(Auto_Delivery.estimated_gallons_left.desc()) + .order_by(Auto_Delivery.estimated_gallons_left.asc()) .all() ) diff --git a/app/routers/main.py b/app/routers/main.py index 6afc541..ca79ed8 100644 --- a/app/routers/main.py +++ b/app/routers/main.py @@ -78,7 +78,7 @@ def update_auto_customers(): elif 5.01 <= today_temptemp_avg <= 10: use_day = 10 elif 0.01 <= today_temptemp_avg <= 5: - use_day =12 + use_day = 12 elif -20 <= today_temptemp_avg <= -1: use_day = 15 else: @@ -98,7 +98,7 @@ def update_auto_customers(): f.estimated_gallons_left = get_gallons_left - + f.last_updated = date.today() session.add(create_new_update) session.add(f) session.commit() diff --git a/app/script/update_auto.py b/app/script/update_auto.py index d297391..e88678e 100644 --- a/app/script/update_auto.py +++ b/app/script/update_auto.py @@ -21,5 +21,6 @@ def calc_home_factor(gallons_put_in_home, current_house_factor): customer_home_factor = Decimal(current_house_factor) - Decimal(.75) else: customer_home_factor = Decimal(current_house_factor) - + if customer_home_factor <= 0: + customer_home_factor = Decimal(.25) return customer_home_factor \ No newline at end of file