fix: deleted user handling

This commit is contained in:
Timothy Jaeryang Baek
2024-11-19 16:47:35 -08:00
parent 011b8ea3a8
commit 0c43c1edf6
54 changed files with 114 additions and 42 deletions

View File

@@ -140,15 +140,18 @@ class ToolsTable:
def get_tools(self) -> list[ToolUserResponse]:
with get_db() as db:
return [
ToolUserResponse.model_validate(
{
**ToolModel.model_validate(tool).model_dump(),
"user": Users.get_user_by_id(tool.user_id).model_dump(),
}
tools = []
for tool in db.query(Tool).order_by(Tool.updated_at.desc()).all():
user = Users.get_user_by_id(tool.user_id)
tools.append(
ToolUserResponse.model_validate(
{
**ToolModel.model_validate(tool).model_dump(),
"user": user.model_dump() if user else None,
}
)
)
for tool in db.query(Tool).order_by(Tool.updated_at.desc()).all()
]
return tools
def get_tools_by_user_id(
self, user_id: str, permission: str = "write"