-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into enhancement/n+1_query-resolve
- Loading branch information
Showing
398 changed files
with
77,110 additions
and
884 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,33 @@ | ||
import os | ||
from typing import Optional | ||
|
||
from fastapi import HTTPException, Request | ||
|
||
from agenta_backend.services import db_manager | ||
from agenta_backend.utils.common import APIRouter | ||
from agenta_backend.models.api.user_models import User | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get("/", operation_id="user_profile") | ||
async def user_profile( | ||
request: Request, | ||
): | ||
@router.get("/", operation_id="fetch_user_profile") | ||
async def user_profile(request: Request, user_id: Optional[str] = None): | ||
try: | ||
user = await db_manager.get_user(request.state.user_id) | ||
if user_id is not None: | ||
user = await db_manager.get_user_with_id(user_id=user_id) | ||
else: | ||
user = await db_manager.get_user(request.state.user_id) | ||
|
||
assert ( | ||
user is not None | ||
), "User not found. Please ensure that the user_id is specified correctly." | ||
return User( | ||
id=str(user.id), | ||
uid=str(user.uid), | ||
username=str(user.username), | ||
email=str(user.email), | ||
username=str(user.username), | ||
created_at=str(user.created_at), | ||
updated_at=str(user.updated_at), | ||
).dict(exclude_unset=True) | ||
).model_dump(exclude_unset=True) | ||
|
||
except Exception as e: | ||
raise HTTPException(status_code=500, detail=str(e)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.