auto working almost

This commit is contained in:
2024-07-17 18:03:58 -04:00
parent 44eeba0841
commit f63da6eb0b
3 changed files with 29 additions and 30 deletions

View File

@@ -7,25 +7,6 @@ from database import Base
# class Auto_Customer(Base):
# __tablename__ = 'auto_customer'
# id = Column(Integer,
# primary_key=True,
# autoincrement=True,
# unique=False)
# customer_id = Column(INTEGER())
# customer_full_name = Column(VARCHAR(250))
# last_fill = Column(TIMESTAMP(), default=datetime.utcnow())
# last_updated = Column(TIMESTAMP(), default=datetime.utcnow())
# estimated_gallons_left = Column(INTEGER)
# estimated_gallons_left_prev_day = Column(INTEGER)
# tank_height = Column(VARCHAR(25))
# tank_size = Column(VARCHAR(25))
# house_factor = Column(DECIMAL(5, 2))
class Auto_Temp(Base):
__tablename__ = 'auto_temp'

View File

@@ -1,5 +1,6 @@
from fastapi import APIRouter
from fastapi.responses import JSONResponse
from fastapi.encoders import jsonable_encoder
from database import session
from pyowm import OWM
@@ -13,13 +14,29 @@ router = APIRouter(
)
@router.get("/{delivery_id_order}", status_code=201)
def get_delivery(delivery_id_order):
@router.route("/all/customers", methods=["GET"])
get_delivery = (
session.query(Auto_Delivery)
.filter(Auto_Delivery.id == delivery_id_order)
.first()
)
return JSONResponse(content=jsonable_encoder(get_delivery), status_code=200)
@router.get("/all/customers")
def get_delivery_customers():
automatics = (
session.query(Auto_Delivery)
.order_by(Auto_Delivery.estimated_gallons_left.desc())
.all()
)
automatics = session.query().filter().first()
return ({"ok": True,
"automatics": automatics
}), 200
return JSONResponse(content=jsonable_encoder(automatics), status_code=200)

View File

@@ -9,9 +9,10 @@ app.include_router(delivery.router)
origins = [
"http://localhost:9000",
"https://localhost:5173",
"http://localhost",
"https://localhost:9513",
"http://localhost:9514",
"http://localhost:9512",
"http://localhost:9511",
]