perf: full text collection and search code;perf: rename function (#3519)

* perf: full text collection and search code

* perf: rename function

* perf: notify modal

* remove invalid code

* perf: sso login

* perf: pay process
This commit is contained in:
Archer
2025-01-03 14:33:13 +08:00
committed by archer
parent 20c6c202d2
commit c0d0c629c5
30 changed files with 423 additions and 270 deletions

View File

@@ -3,7 +3,8 @@ import type { OrgSchemaType } from '@fastgpt/global/support/user/team/org/type';
import type { ClientSession } from 'mongoose';
import { MongoOrgModel } from './orgSchema';
import { MongoOrgMemberModel } from './orgMemberSchema';
import { getChildrenPath } from '@fastgpt/global/support/user/team/org/constant';
import { getOrgChildrenPath } from '@fastgpt/global/support/user/team/org/constant';
import { getNanoid } from '@fastgpt/global/common/string/tools';
export const getOrgsByTmbId = async ({ teamId, tmbId }: { teamId: string; tmbId: string }) =>
MongoOrgMemberModel.find({ teamId, tmbId }, 'orgId').lean();
@@ -43,9 +44,13 @@ export const getChildrenByOrg = async ({
teamId: string;
session?: ClientSession;
}) => {
return MongoOrgModel.find({ teamId, path: { $regex: `^${getChildrenPath(org)}` } }, undefined, {
session
}).lean();
return MongoOrgModel.find(
{ teamId, path: { $regex: `^${getOrgChildrenPath(org)}` } },
undefined,
{
session
}
).lean();
};
export const getOrgAndChildren = async ({

View File

@@ -6,10 +6,6 @@ import { OrgMemberCollectionName } from './orgMemberSchema';
import { getNanoid } from '@fastgpt/global/common/string/tools';
const { Schema } = connectionMongo;
function requiredStringPath(this: OrgSchemaType) {
return typeof this.path !== 'string';
}
export const OrgSchema = new Schema(
{
teamId: {
@@ -25,7 +21,9 @@ export const OrgSchema = new Schema(
},
path: {
type: String,
required: requiredStringPath // allow empty string, but not null
required: function (this: OrgSchemaType) {
return typeof this.path !== 'string';
} // allow empty string, but not null
},
name: {
type: String,

View File

@@ -79,10 +79,10 @@ const UserSchema = new Schema({
try {
// login
UserSchema.index({ username: 1, password: 1 }, { background: true });
UserSchema.index({ username: 1 });
// Admin charts
UserSchema.index({ createTime: -1 }, { background: true });
UserSchema.index({ createTime: -1 });
} catch (error) {
console.log(error);
}

View File

@@ -1,3 +0,0 @@
export function isWecomTerminal() {
return /wxwork/i.test(navigator.userAgent);
}

View File

@@ -61,11 +61,11 @@ const UsageSchema = new Schema({
});
try {
UsageSchema.index({ teamId: 1, tmbId: 1, source: 1, time: -1 }, { background: true });
UsageSchema.index({ teamId: 1, tmbId: 1, source: 1, time: -1 });
// timer task. clear dead team
// UsageSchema.index({ teamId: 1, time: -1 }, { background: true });
// UsageSchema.index({ teamId: 1, time: -1 });
UsageSchema.index({ time: 1 }, { background: true, expireAfterSeconds: 360 * 24 * 60 * 60 });
UsageSchema.index({ time: 1 }, { expireAfterSeconds: 360 * 24 * 60 * 60 });
} catch (error) {
console.log(error);
}