Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docSite/content/zh-cn/docs/development/upgrading/498.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ weight: 792

## ⚙️ 优化

1. Chat log list 优化,避免大数据时超出内存限制。

## 🐛 修复

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ const JsonImportModal = ({ onClose }: { onClose: () => void }) => {
onSuccess(id: string) {
router.push(`/app/detail?appId=${id}`);
loadMyApps();
onClose();
removeUtmParams();
removeUtmWorkflow();
handleCloseJsonImportModal();
},
successToast: t('common:common.Create Success')
}
Expand Down
107 changes: 18 additions & 89 deletions projects/app/src/pages/api/core/app/getChatLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,108 +74,37 @@ async function handler(
}
}
},
{ $count: 'messageCount' }
],
as: 'messageCountData'
}
},
{
$lookup: {
from: ChatItemCollectionName,
let: { chatId: '$chatId', appId: new Types.ObjectId(appId) },
pipeline: [
{
$match: {
$expr: {
$and: [
{ $eq: ['$appId', '$$appId'] },
{ $eq: ['$chatId', '$$chatId'] },
{ $eq: ['$userGoodFeedback', true] }
]
}
}
},
{ $count: 'count' }
],
as: 'userGoodFeedbackData'
}
},
{
$lookup: {
from: ChatItemCollectionName,
let: { chatId: '$chatId', appId: new Types.ObjectId(appId) },
pipeline: [
{
$match: {
$expr: {
$and: [
{ $eq: ['$appId', '$$appId'] },
{ $eq: ['$chatId', '$$chatId'] },
{ $eq: ['$userBadFeedback', true] }
]
}
}
},
{ $count: 'count' }
],
as: 'userBadFeedbackData'
}
},
{
$lookup: {
from: ChatItemCollectionName,
let: { chatId: '$chatId', appId: new Types.ObjectId(appId) },
pipeline: [
{
$match: {
$expr: {
$and: [
{ $eq: ['$appId', '$$appId'] },
{ $eq: ['$chatId', '$$chatId'] },
{ $gt: [{ $size: { $ifNull: ['$customFeedbacks', []] } }, 0] }
]
}
$group: {
_id: null,
messageCount: { $sum: 1 },
goodFeedback: { $sum: { $cond: [{ $eq: ['$userGoodFeedback', true] }, 1, 0] } },
badFeedback: { $sum: { $cond: [{ $eq: ['$userBadFeedback', true] }, 1, 0] } },
customFeedback: {
$sum: {
$cond: [{ $gt: [{ $size: { $ifNull: ['$customFeedbacks', []] } }, 0] }, 1, 0]
}
},
adminMark: { $sum: { $cond: [{ $eq: ['$adminFeedback', true] }, 1, 0] } }
}
},
{ $count: 'count' }
],
as: 'customFeedbacksData'
}
},
{
$lookup: {
from: ChatItemCollectionName,
let: { chatId: '$chatId', appId: new Types.ObjectId(appId) },
pipeline: [
{
$match: {
$expr: {
$and: [
{ $eq: ['$appId', '$$appId'] },
{ $eq: ['$chatId', '$$chatId'] },
{ $eq: ['$adminFeedback', true] }
]
}
}
},
{ $count: 'count' }
}
],
as: 'markData'
as: 'chatItemsData'
}
},
{
$addFields: {
messageCount: { $ifNull: [{ $arrayElemAt: ['$chatItemsData.messageCount', 0] }, 0] },
userGoodFeedbackCount: {
$ifNull: [{ $arrayElemAt: ['$userGoodFeedbackData.count', 0] }, 0]
$ifNull: [{ $arrayElemAt: ['$chatItemsData.goodFeedback', 0] }, 0]
},
userBadFeedbackCount: {
$ifNull: [{ $arrayElemAt: ['$userBadFeedbackData.count', 0] }, 0]
$ifNull: [{ $arrayElemAt: ['$chatItemsData.badFeedback', 0] }, 0]
},
customFeedbacksCount: {
$ifNull: [{ $arrayElemAt: ['$customFeedbacksData.count', 0] }, 0]
$ifNull: [{ $arrayElemAt: ['$chatItemsData.customFeedback', 0] }, 0]
},
markCount: { $ifNull: [{ $arrayElemAt: ['$markData.count', 0] }, 0] },
messageCount: { $ifNull: [{ $arrayElemAt: ['$messageCountData.messageCount', 0] }, 0] }
markCount: { $ifNull: [{ $arrayElemAt: ['$chatItemsData.adminMark', 0] }, 0] }
}
},
{
Expand Down
1 change: 1 addition & 0 deletions projects/app/src/web/context/useInitApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const useInitApp = () => {
const router = useRouter();
const { hiId, bd_vid, k, sourceDomain, utm_source, utm_medium, utm_content, utm_workflow } =
router.query as MarketingQueryParams;

const { loadGitStar, setInitd, feConfigs } = useSystemStore();
const { userInfo } = useUserStore();
const [scripts, setScripts] = useState<FastGPTFeConfigsType['scripts']>([]);
Expand Down
Loading