fix: session data response
This commit is contained in:
parent
cbdce3da20
commit
4203db07af
|
@ -13,6 +13,7 @@ class SessionController(MethodView):
|
|||
required_fields = [
|
||||
"quiz_id",
|
||||
"host_id",
|
||||
"room_name",
|
||||
"limit_participan",
|
||||
]
|
||||
for field in required_fields:
|
||||
|
@ -22,6 +23,7 @@ class SessionController(MethodView):
|
|||
session = self.session_service.create_session(
|
||||
quiz_id=data["quiz_id"],
|
||||
host_id=data["host_id"],
|
||||
room_name=data["room_name"],
|
||||
limit_participan=data["limit_participan"],
|
||||
)
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ class SessionEntity(BaseModel):
|
|||
session_code: str
|
||||
quiz_id: str
|
||||
host_id: str
|
||||
room_name: str
|
||||
created_at: datetime = Field(default_factory=datetime.now)
|
||||
started_at: datetime | None = None
|
||||
ended_at: datetime | None = None
|
||||
|
|
|
@ -38,12 +38,19 @@ class SessionService:
|
|||
self.quiz_repository = quiz_repository
|
||||
self.answer_repository = answer_repository
|
||||
|
||||
def create_session(self, quiz_id: str, host_id: str, limit_participan: int) -> str:
|
||||
def create_session(
|
||||
self,
|
||||
quiz_id: str,
|
||||
host_id: str,
|
||||
room_name: str,
|
||||
limit_participan: int,
|
||||
) -> str:
|
||||
generateed_code = uuid4().hex[:6].upper()
|
||||
session = SessionEntity(
|
||||
session_code=generateed_code,
|
||||
quiz_id=quiz_id,
|
||||
host_id=host_id,
|
||||
room_name=room_name,
|
||||
created_at=DatetimeUtil.now_iso(),
|
||||
limit_participan=limit_participan,
|
||||
participants=[],
|
||||
|
|
Loading…
Reference in New Issue