refactor: rename RawResponse to ScaleResult for improved clarity
- Updated the database model from RawResponse to ScaleResult to better reflect its purpose. - Adjusted the result handling logic in app.py to utilize the new ScaleResult model for storing user responses.
This commit is contained in:
parent
ce020a5674
commit
90720b3cec
4
app.py
4
app.py
@ -9,7 +9,7 @@ import uvicorn
|
||||
from datetime import datetime
|
||||
from xml.etree import ElementTree as ET
|
||||
from sqlalchemy.orm import Session
|
||||
from database import get_db, RawResponse
|
||||
from database import get_db, ScaleResult
|
||||
import geoip2.database
|
||||
|
||||
app = FastAPI()
|
||||
@ -126,7 +126,7 @@ async def result(request: Request, scale_id: str, db: Session = Depends(get_db))
|
||||
request.headers.get("X-Real-IP", "") or \
|
||||
request.client.host # Get real IP address considering proxy headers
|
||||
location = get_location_from_ip(ip)# Get location information
|
||||
db_response = RawResponse(
|
||||
db_response = ScaleResult(
|
||||
scale_id=scale_id,
|
||||
user_agent=request.headers.get("user-agent", "Unknown"),
|
||||
ip_address=ip,
|
||||
|
@ -15,7 +15,7 @@ SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
class Response(Base):
|
||||
class ScaleResult(Base):
|
||||
__tablename__ = "responses"
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
scale_id = Column(String, index=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user