Update with filter for audit

This commit is contained in:
Saurab-Shrestha9639*969**9858//852 2024-04-21 16:52:45 +05:45
parent 8bc7fb0039
commit 97317b82e0
7 changed files with 91 additions and 8 deletions

View file

@ -11,12 +11,20 @@ from private_gpt.users.schemas.chat import ChatHistoryCreate, ChatHistoryCreate,
class CRUDChat(CRUDBase[ChatHistory, ChatHistoryCreate, ChatHistoryCreate]):
def get_by_id(self, db: Session, *, id: uuid.UUID) -> Optional[ChatHistory]:
return (
db.query(self.model)
.filter(ChatHistory.conversation_id == id)
.order_by(asc(getattr(ChatHistory, 'created_at')))
.first()
chat_history = (
db.query(self.model)
.filter(ChatHistory.conversation_id == id)
.order_by(asc(getattr(ChatHistory, 'created_at')))
.first()
)
if chat_history:
chat_history.chat_items = (
db.query(ChatItem)
.filter(ChatItem.conversation_id == id)
.order_by(asc(getattr(ChatItem, 'index')))
.all()
)
return chat_history
def get_chat_history(
self, db: Session, *,user_id:int, skip: int = 0, limit: int = 100