Working site
This commit is contained in:
@@ -3,7 +3,7 @@ from database import session
|
||||
|
||||
from app.script.fuel_estimator import FuelEstimator
|
||||
from app.script.temp_getter import fetch_and_store_daily_temp
|
||||
|
||||
from app.script.fuel_estimator_customer import FuelEstimatorCustomer
|
||||
router = APIRouter(
|
||||
prefix="/main",
|
||||
tags=["main"],
|
||||
@@ -31,8 +31,8 @@ def update_temp_manually():
|
||||
|
||||
|
||||
|
||||
@router.get("/update", status_code=200)
|
||||
def update_all_customer_fuel_levels():
|
||||
@router.get("/update/auto", status_code=200)
|
||||
def update_all_customer_fuel_levels_auto():
|
||||
"""
|
||||
This endpoint triggers the daily update for all customers.
|
||||
It should be called once per day by a cron job or scheduler.
|
||||
@@ -47,3 +47,21 @@ def update_all_customer_fuel_levels():
|
||||
# Log the exception e
|
||||
print(str(e))
|
||||
return {"ok": False, "message": "An internal error occurred."}
|
||||
|
||||
|
||||
@router.get("/update/normal", status_code=200)
|
||||
def update_all_customer_fuel_levels_normal():
|
||||
"""
|
||||
This endpoint triggers the daily update for all customers.
|
||||
It should be called once per day by a cron job or scheduler.
|
||||
"""
|
||||
try:
|
||||
estimator = FuelEstimatorCustomer(session)
|
||||
result = estimator.run_daily_update()
|
||||
session.commit()
|
||||
return result
|
||||
except Exception as e:
|
||||
session.rollback()
|
||||
# Log the exception e
|
||||
print(str(e))
|
||||
return {"ok": False, "message": "An internal error occurred."}
|
||||
|
||||
Reference in New Issue
Block a user