From fffccd55258d9697c8acba5777ffb1e8a728dff7 Mon Sep 17 00:00:00 2001 From: Lukas Holzner Date: Tue, 1 Oct 2024 12:03:52 +0200 Subject: [PATCH] Added get meetings with conversation status for userid --- backend/app/routers/meetings.py | 16 ++++++++++++++++ backend/app/schemas.py | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/backend/app/routers/meetings.py b/backend/app/routers/meetings.py index 47d0862..c86a88c 100644 --- a/backend/app/routers/meetings.py +++ b/backend/app/routers/meetings.py @@ -134,6 +134,22 @@ def read_meetings(skip: int = 0, limit: int = 100, db: Session = Depends(get_db) meetings = get_meetings(db, skip=skip, limit=limit) return meetings +@router.get("/meetings/{user_id}", response_model=List[schemas.MeetingStatusUser]) +def read_meetings_by_user(user_id: int, db: Session = Depends(get_db)): + status_meetings = [] + meetings = get_meetings(db) + for meeting in meetings: + conversation = get_conversation(db, meeting_id=meeting.id, user_id=user_id) + if conversation is None: + meeting_status = "todo" + else: + if conversation.finished: + meeting_status = "done" + else: + meeting_status = "in_progress" + status_meetings.append(schemas.MeetingStatusUser(conversation_status=meeting_status, meeting=meeting)) + return status_meetings + @router.get("/meetings/{meeting_id}", response_model=schemas.MeetingSchema) def read_meeting_route(meeting_id: int, db: Session = Depends(get_db)): db_meeting = get_meeting(db, meeting_id=meeting_id) diff --git a/backend/app/schemas.py b/backend/app/schemas.py index c0bd749..1dd0ddf 100644 --- a/backend/app/schemas.py +++ b/backend/app/schemas.py @@ -55,5 +55,16 @@ class Conversation(BaseModel): system_prompt: str = "EMPTY" finished: bool = False +class ConversationStatus(str, Enum): + TODO = "todo" + IN_PROGRESS = "in_progress" + DONE = "done" + +class MeetingStatusUser(BaseModel): + conversation_status: ConversationStatus + meeting: Meeting + + +