mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-30 18:48:55 +00:00
perf:change plugin version update position (#1493)
* perf:change plugin version update position * use nodeversion
This commit is contained in:
@@ -7,6 +7,8 @@ import { MongoPlugin } from '@fastgpt/service/core/plugin/schema';
|
||||
import { mongoSessionRun } from '@fastgpt/service/common/mongo/sessionRun';
|
||||
import { ClientSession } from '@fastgpt/service/common/mongo';
|
||||
import { httpApiSchema2Plugins } from '@fastgpt/global/core/plugin/httpPlugin/utils';
|
||||
import { isEqual } from 'lodash';
|
||||
import { nanoid } from 'nanoid';
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
|
||||
try {
|
||||
@@ -22,7 +24,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
||||
per: 'owner'
|
||||
});
|
||||
|
||||
const updateData = {
|
||||
const originPlugin = await MongoPlugin.findById(id);
|
||||
|
||||
let updateData = {
|
||||
name: props.name,
|
||||
intro: props.intro,
|
||||
avatar: props.avatar,
|
||||
@@ -32,9 +36,26 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
||||
modules: modules
|
||||
}),
|
||||
...(edges?.length && { edges }),
|
||||
metadata: props.metadata
|
||||
metadata: props.metadata,
|
||||
nodeVersion: originPlugin?.nodeVersion
|
||||
};
|
||||
|
||||
const isNodeVersionEqual =
|
||||
isEqual(
|
||||
originPlugin?.modules.map((module) => {
|
||||
return { ...module, position: undefined };
|
||||
}),
|
||||
updateData.modules?.map((module) => {
|
||||
return { ...module, position: undefined };
|
||||
})
|
||||
) && isEqual(originPlugin?.edges, updateData.edges);
|
||||
|
||||
if (!isNodeVersionEqual) {
|
||||
updateData = {
|
||||
...updateData,
|
||||
nodeVersion: nanoid(6)
|
||||
};
|
||||
}
|
||||
if (props.metadata?.apiSchemaStr) {
|
||||
await mongoSessionRun(async (session) => {
|
||||
// update children
|
||||
|
Reference in New Issue
Block a user