Updated claude big changes
This commit is contained in:
0
app/common/__init__.py
Normal file
0
app/common/__init__.py
Normal file
53
app/common/responses.py
Normal file
53
app/common/responses.py
Normal file
@@ -0,0 +1,53 @@
|
||||
"""
|
||||
Standardized API response utilities for FastAPI services.
|
||||
|
||||
Usage:
|
||||
from app.common.responses import error_response, success_response
|
||||
|
||||
# Error responses
|
||||
return error_response("User not found", 404)
|
||||
return error_response("Invalid credentials", 401)
|
||||
|
||||
# Success responses
|
||||
return success_response({"user": user_data})
|
||||
return success_response({"message": "Created"}, 201)
|
||||
"""
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
|
||||
def error_response(message: str, status_code: int = 400, details: str = None) -> JSONResponse:
|
||||
"""
|
||||
Create a standardized error response.
|
||||
|
||||
Args:
|
||||
message: Human-readable error message
|
||||
status_code: HTTP status code (default 400)
|
||||
details: Optional additional details (e.g., exception info)
|
||||
|
||||
Returns:
|
||||
JSONResponse with error data
|
||||
"""
|
||||
content = {
|
||||
"ok": False,
|
||||
"error": message
|
||||
}
|
||||
if details:
|
||||
content["details"] = details
|
||||
return JSONResponse(content=content, status_code=status_code)
|
||||
|
||||
|
||||
def success_response(data: dict = None, status_code: int = 200) -> JSONResponse:
|
||||
"""
|
||||
Create a standardized success response.
|
||||
|
||||
Args:
|
||||
data: Response data dictionary
|
||||
status_code: HTTP status code (default 200)
|
||||
|
||||
Returns:
|
||||
JSONResponse with success data
|
||||
"""
|
||||
content = {"ok": True}
|
||||
if data:
|
||||
content.update(data)
|
||||
return JSONResponse(content=content, status_code=status_code)
|
||||
20
app/constants.py
Normal file
20
app/constants.py
Normal file
@@ -0,0 +1,20 @@
|
||||
"""
|
||||
EAMCO Auto API Constants
|
||||
|
||||
This file contains tank configuration and other constants used throughout
|
||||
the auto-delivery management service.
|
||||
"""
|
||||
|
||||
# Default tank size in gallons (most common residential oil tank)
|
||||
DEFAULT_TANK_SIZE_GALLONS = 275
|
||||
|
||||
# Maximum fill amounts for different tank sizes (gallons we can actually fill)
|
||||
# Tanks cannot be filled to 100% capacity for safety reasons
|
||||
TANK_MAX_FILLS = {
|
||||
275: 240,
|
||||
330: 280,
|
||||
500: 475,
|
||||
}
|
||||
|
||||
# Default max fill when tank size is unknown (based on 275 gallon tank)
|
||||
DEFAULT_MAX_FILL_GALLONS = 240
|
||||
@@ -9,6 +9,7 @@ from decimal import Decimal
|
||||
|
||||
from app.models.auto import Auto_Delivery, Tickets_Auto_Delivery, Auto_Temp
|
||||
from app.models.delivery import Delivery
|
||||
from app.constants import DEFAULT_TANK_SIZE_GALLONS
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -90,9 +91,9 @@ def estimate_customer_gallons(update_db: int):
|
||||
).order_by(Tickets_Auto_Delivery.fill_date).all()
|
||||
|
||||
# Get tank size and hot water setting
|
||||
tank_size = Decimal(ad.tank_size) if ad.tank_size else Decimal('275')
|
||||
tank_size = Decimal(ad.tank_size) if ad.tank_size else Decimal(DEFAULT_TANK_SIZE_GALLONS)
|
||||
# Adjust effective tank capacity (not filled to 100%)
|
||||
if tank_size == 275:
|
||||
if tank_size == DEFAULT_TANK_SIZE_GALLONS:
|
||||
effective_tank = Decimal('250')
|
||||
elif tank_size == 330:
|
||||
effective_tank = Decimal('300')
|
||||
|
||||
Reference in New Issue
Block a user