From ce020a56741490b4475452b4eeffcce38b7225ab Mon Sep 17 00:00:00 2001 From: mxr612 Date: Mon, 16 Jun 2025 06:47:40 +0800 Subject: [PATCH] refactor: update response model and location handling - Renamed RawResponse model to Response for clarity. - Changed location field type from String to JSON in the Response model. - Updated result handling logic to store location as a JSON object instead of a string. --- app.py | 2 +- database.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 234fc62..f71cc35 100644 --- a/app.py +++ b/app.py @@ -130,7 +130,7 @@ async def result(request: Request, scale_id: str, db: Session = Depends(get_db)) scale_id=scale_id, user_agent=request.headers.get("user-agent", "Unknown"), ip_address=ip, - location=json.dumps(location) if location else None, + location=location, raw_response=dict(form_data), sum_response=responses, avg_response=average diff --git a/database.py b/database.py index 2488466..47c6c34 100644 --- a/database.py +++ b/database.py @@ -15,13 +15,13 @@ SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) Base = declarative_base() -class RawResponse(Base): +class Response(Base): __tablename__ = "responses" id = Column(Integer, primary_key=True, index=True) scale_id = Column(String, index=True) user_agent = Column(String) ip_address = Column(String) - location = Column(String) + location = Column(JSON) raw_response = Column(JSON) sum_response = Column(JSON) avg_response = Column(JSON)