From 90720b3cec9924a6bc86eade423ca36963c2291d Mon Sep 17 00:00:00 2001 From: mxr612 Date: Mon, 16 Jun 2025 06:50:25 +0800 Subject: [PATCH] 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. --- app.py | 4 ++-- database.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index f71cc35..5b9997b 100644 --- a/app.py +++ b/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, diff --git a/database.py b/database.py index 47c6c34..e193681 100644 --- a/database.py +++ b/database.py @@ -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)