perf: chat history api;perf: full text error (#4852)

* perf: chat history api

* perf: i18n

* perf: full text
This commit is contained in:
Archer
2025-05-20 22:31:32 +08:00
committed by GitHub
parent 89c9a02650
commit aa55f059d4
12 changed files with 192 additions and 124 deletions

View File

@@ -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 & {

View File

@@ -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 */}

View File

@@ -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 {