mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-04 09:39:32 +08:00
@@ -76,42 +76,19 @@ type ListChatsResponse struct {
|
||||
|
||||
// ListChats list chats for a user
|
||||
func (s *ChatService) ListChats(userID, status, keywords string, page, pageSize int, orderby string, desc bool) (*ListChatsResponse, error) {
|
||||
// Get tenant IDs by user ID
|
||||
tenantIDs, err := s.userTenantDAO.GetTenantIDsByUserID(userID)
|
||||
chats, total, err := s.chatDAO.ListByTenantIDs(
|
||||
nil,
|
||||
userID,
|
||||
page,
|
||||
pageSize,
|
||||
orderby,
|
||||
desc,
|
||||
keywords,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// For now, use the first tenant ID (primary tenant)
|
||||
// This matches the Python implementation behavior
|
||||
var tenantID string
|
||||
if len(tenantIDs) > 0 {
|
||||
tenantID = tenantIDs[0]
|
||||
} else {
|
||||
tenantID = userID
|
||||
}
|
||||
|
||||
// Query chats by tenant ID
|
||||
chats, err := s.chatDAO.ListByTenantID(tenantID, status)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
total := int64(len(chats))
|
||||
|
||||
if page > 0 && pageSize > 0 {
|
||||
start := (page - 1) * pageSize
|
||||
end := start + pageSize
|
||||
if start < int(total) {
|
||||
if end > int(total) {
|
||||
end = int(total)
|
||||
}
|
||||
chats = chats[start:end]
|
||||
} else {
|
||||
chats = []*entity.Chat{}
|
||||
}
|
||||
}
|
||||
|
||||
// Enrich with knowledge base names
|
||||
chatsWithKBNames := make([]*ChatWithKBNames, 0, len(chats))
|
||||
for _, chat := range chats {
|
||||
|
||||
Reference in New Issue
Block a user