mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00
Record scroll test (#2783)
* perf: history add scrollList (#2696) * perf: chatHistorySlider add virtualList * perf: chat records add scrollList * delete console * perf: ScrollData add ref props * 优化代码 * optimize code && add line breaks * add total records display * finish test * perf: ScrollComponent load data * perf: Scroll components load * perf: scroll code --------- Co-authored-by: papapatrick <109422393+Patrickill@users.noreply.github.com>
This commit is contained in:
@@ -9,23 +9,24 @@ import { MongoChat } from './chatSchema';
|
||||
export async function getChatItems({
|
||||
appId,
|
||||
chatId,
|
||||
limit = 30,
|
||||
offset,
|
||||
limit,
|
||||
field
|
||||
}: {
|
||||
appId: string;
|
||||
chatId?: string;
|
||||
limit?: number;
|
||||
offset: number;
|
||||
limit: number;
|
||||
field: string;
|
||||
}): Promise<{ histories: ChatItemType[] }> {
|
||||
}): Promise<{ histories: ChatItemType[]; total: number }> {
|
||||
if (!chatId) {
|
||||
return { histories: [] };
|
||||
return { histories: [], total: 0 };
|
||||
}
|
||||
|
||||
const histories = await MongoChatItem.find({ appId, chatId }, field)
|
||||
.sort({ _id: -1 })
|
||||
.limit(limit)
|
||||
.lean();
|
||||
|
||||
const [histories, total] = await Promise.all([
|
||||
MongoChatItem.find({ chatId, appId }, field).sort({ _id: -1 }).skip(offset).limit(limit).lean(),
|
||||
MongoChatItem.countDocuments({ chatId, appId })
|
||||
]);
|
||||
histories.reverse();
|
||||
|
||||
histories.forEach((item) => {
|
||||
@@ -33,7 +34,7 @@ export async function getChatItems({
|
||||
item.value = adaptStringValue(item.value);
|
||||
});
|
||||
|
||||
return { histories };
|
||||
return { histories, total };
|
||||
}
|
||||
|
||||
/* Temporary adaptation for old conversation records */
|
||||
|
Reference in New Issue
Block a user