feat: chat export

This commit is contained in:
Timothy J. Baek 2023-12-26 22:10:22 -08:00
parent a2b1e3756b
commit 4221594778
5 changed files with 81 additions and 11 deletions

View file

@ -123,6 +123,14 @@ class ChatTable:
# .offset(skip)
]
def get_all_chats_by_user_id(self, user_id: str) -> List[ChatModel]:
return [
ChatModel(**model_to_dict(chat))
for chat in Chat.select()
.where(Chat.user_id == user_id)
.order_by(Chat.timestamp.desc())
]
def get_chat_by_id_and_user_id(self, id: str, user_id: str) -> Optional[ChatModel]:
try:
chat = Chat.get(Chat.id == id, Chat.user_id == user_id)