mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00
perf: chat history api;perf: full text error (#4852)
* perf: chat history api * perf: i18n * perf: full text
This commit is contained in:
5
projects/app/src/global/core/chat/api.d.ts
vendored
5
projects/app/src/global/core/chat/api.d.ts
vendored
@@ -60,6 +60,11 @@ export type InitChatResponse = {
|
||||
export type GetHistoriesProps = OutLinkChatAuthProps & {
|
||||
appId?: string;
|
||||
source?: `${ChatSourceEnum}`;
|
||||
|
||||
startCreateTime?: string;
|
||||
endCreateTime?: string;
|
||||
startUpdateTime?: string;
|
||||
endUpdateTime?: string;
|
||||
};
|
||||
|
||||
export type UpdateHistoryProps = OutLinkChatAuthProps & {
|
||||
|
@@ -89,7 +89,7 @@ const Standard = ({
|
||||
mb={2}
|
||||
mr={'-2'}
|
||||
>
|
||||
{t('common:support.wallet.subscription.mode.Ten Year')}
|
||||
{t('common:pay_year_tip')}
|
||||
</Box>
|
||||
<RowTabs
|
||||
list={[
|
||||
@@ -110,7 +110,7 @@ const Standard = ({
|
||||
onChange={(e) => setSelectSubMode(e as `${SubModeEnum}`)}
|
||||
/>
|
||||
</Box>
|
||||
<MyIcon name={'price/pricearrow'} mt={'10px'} ml={'3px'} />
|
||||
<MyIcon name={'price/pricearrow'} mt={'10px'} ml={'6px'} />
|
||||
</Flex>
|
||||
|
||||
{/* card */}
|
||||
|
@@ -20,7 +20,18 @@ async function handler(
|
||||
req: ApiRequestProps<getHistoriesBody, getHistoriesQuery>,
|
||||
_res: ApiResponseType<any>
|
||||
): Promise<PaginationResponse<getHistoriesResponse>> {
|
||||
const { appId, shareId, outLinkUid, teamId, teamToken, source } = req.body;
|
||||
const {
|
||||
appId,
|
||||
shareId,
|
||||
outLinkUid,
|
||||
teamId,
|
||||
teamToken,
|
||||
source,
|
||||
startCreateTime,
|
||||
endCreateTime,
|
||||
startUpdateTime,
|
||||
endUpdateTime
|
||||
} = req.body;
|
||||
const { offset, pageSize } = parsePaginationRequest(req);
|
||||
|
||||
const match = await (async () => {
|
||||
@@ -49,7 +60,7 @@ async function handler(
|
||||
return {
|
||||
tmbId,
|
||||
appId,
|
||||
source
|
||||
...(source && { source })
|
||||
};
|
||||
}
|
||||
})();
|
||||
@@ -61,13 +72,29 @@ async function handler(
|
||||
};
|
||||
}
|
||||
|
||||
const timeMatch: Record<string, any> = {};
|
||||
if (startCreateTime || endCreateTime) {
|
||||
timeMatch.createTime = {
|
||||
...(startCreateTime && { $gte: new Date(startCreateTime) }),
|
||||
...(endCreateTime && { $lte: new Date(endCreateTime) })
|
||||
};
|
||||
}
|
||||
if (startUpdateTime || endUpdateTime) {
|
||||
timeMatch.updateTime = {
|
||||
...(startUpdateTime && { $gte: new Date(startUpdateTime) }),
|
||||
...(endUpdateTime && { $lte: new Date(endUpdateTime) })
|
||||
};
|
||||
}
|
||||
|
||||
const mergeMatch = { ...match, ...timeMatch };
|
||||
|
||||
const [data, total] = await Promise.all([
|
||||
await MongoChat.find(match, 'chatId title top customTitle appId updateTime')
|
||||
await MongoChat.find(mergeMatch, 'chatId title top customTitle appId updateTime')
|
||||
.sort({ top: -1, updateTime: -1 })
|
||||
.skip(offset)
|
||||
.limit(pageSize)
|
||||
.lean(),
|
||||
MongoChat.countDocuments(match)
|
||||
MongoChat.countDocuments(mergeMatch)
|
||||
]);
|
||||
|
||||
return {
|
||||
|
Reference in New Issue
Block a user