user-feedback / db /schema.py
Ashmi Banerjee
first draft
9a6b7dc
raw
history blame
566 Bytes
from pydantic import BaseModel
from typing import List, Dict
from datetime import datetime
class Response(BaseModel):
q_id: str
ans: int
feedback_text: str | None = None
class Feedback(BaseModel):
id: int
user_id: str
time_stamp: datetime
responses: List[Response]
# Override the method to serialize datetime
def dict(self, *args, **kwargs):
feedback_data = super().dict(*args, **kwargs)
feedback_data['time_stamp'] = self.time_stamp.isoformat() # Convert datetime to ISO string
return feedback_data