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.
This commit is contained in:
parent
7cb36eb1af
commit
ce020a5674
2
app.py
2
app.py
@ -130,7 +130,7 @@ async def result(request: Request, scale_id: str, db: Session = Depends(get_db))
|
|||||||
scale_id=scale_id,
|
scale_id=scale_id,
|
||||||
user_agent=request.headers.get("user-agent", "Unknown"),
|
user_agent=request.headers.get("user-agent", "Unknown"),
|
||||||
ip_address=ip,
|
ip_address=ip,
|
||||||
location=json.dumps(location) if location else None,
|
location=location,
|
||||||
raw_response=dict(form_data),
|
raw_response=dict(form_data),
|
||||||
sum_response=responses,
|
sum_response=responses,
|
||||||
avg_response=average
|
avg_response=average
|
||||||
|
@ -15,13 +15,13 @@ SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
|||||||
|
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
|
|
||||||
class RawResponse(Base):
|
class Response(Base):
|
||||||
__tablename__ = "responses"
|
__tablename__ = "responses"
|
||||||
id = Column(Integer, primary_key=True, index=True)
|
id = Column(Integer, primary_key=True, index=True)
|
||||||
scale_id = Column(String, index=True)
|
scale_id = Column(String, index=True)
|
||||||
user_agent = Column(String)
|
user_agent = Column(String)
|
||||||
ip_address = Column(String)
|
ip_address = Column(String)
|
||||||
location = Column(String)
|
location = Column(JSON)
|
||||||
raw_response = Column(JSON)
|
raw_response = Column(JSON)
|
||||||
sum_response = Column(JSON)
|
sum_response = Column(JSON)
|
||||||
avg_response = Column(JSON)
|
avg_response = Column(JSON)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user