chore: formatting

This commit is contained in:
Aryan Kothari 2024-07-22 14:45:47 -04:00
parent a0667dfd1b
commit f531a51e91

View File

@ -244,6 +244,7 @@ class ChatTable:
.all() .all()
) )
return [ChatModel.model_validate(chat) for chat in all_chats] return [ChatModel.model_validate(chat) for chat in all_chats]
def get_chat_title_id_list_by_user_id( def get_chat_title_id_list_by_user_id(
self, self,
user_id: str, user_id: str,
@ -259,17 +260,24 @@ class ChatTable:
all_chats = ( all_chats = (
query.order_by(Chat.updated_at.desc()) query.order_by(Chat.updated_at.desc())
# limit cols # limit cols
.with_entities(Chat.id, Chat.title, Chat.updated_at, Chat.created_at) .with_entities(
.all() Chat.id, Chat.title, Chat.updated_at, Chat.created_at
).all()
) )
# result has to be destrctured from sqlalchemy `row` and mapped to a dict since the `ChatModel`is not the returned dataclass. # result has to be destrctured from sqlalchemy `row` and mapped to a dict since the `ChatModel`is not the returned dataclass.
return list(map(lambda row: ChatTitleIdResponse.model_validate({ return list(
map(
lambda row: ChatTitleIdResponse.model_validate(
{
"id": row[0], "id": row[0],
"title": row[1], "title": row[1],
"updated_at": row[2], "updated_at": row[2],
"created_at": row[3] "created_at": row[3],
}), all_chats)) }
),
all_chats,
)
)
def get_chat_list_by_chat_ids( def get_chat_list_by_chat_ids(
self, chat_ids: List[str], skip: int = 0, limit: int = 50 self, chat_ids: List[str], skip: int = 0, limit: int = 50