perf: perf request

This commit is contained in:
xion 2025-04-07 17:04:48 +08:00
parent 226f9a6896
commit fe716b8ea3
2 changed files with 8 additions and 1 deletions

View File

@ -11,10 +11,15 @@ app
.define(async (ctx) => { .define(async (ctx) => {
const tokenUser = ctx.state.tokenUser; const tokenUser = ctx.state.tokenUser;
const type = ctx.query.type || 'keep'; const type = ctx.query.type || 'keep';
const all = ctx.query.all || false;
let search: any = {};
if (type && !all) {
search.type = type;
}
const aiChatList = await AiChatHistoryModel.findAll({ const aiChatList = await AiChatHistoryModel.findAll({
where: { where: {
uid: tokenUser.id, uid: tokenUser.id,
type, ...search,
}, },
order: [['updatedAt', 'DESC']], order: [['updatedAt', 'DESC']],
}); });

View File

@ -18,6 +18,8 @@ type AiChatHistoryData = {
[key: string]: any; [key: string]: any;
}; };
}; };
export const aiChatTypes = ['keep', 'temp', 'archive'] as const;
export type AIChatType = (typeof aiChatTypes)[number];
export class AiChatHistoryModel extends Model { export class AiChatHistoryModel extends Model {
declare id: string; declare id: string;
declare username: string; declare username: string;