4.14.4 features (#6090)

* perf: zod with app log (#6083)

* perf: safe decode

* perf: zod with app log

* fix: text

* remove log

* rename field

* refactor: improve like/dislike interaction (#6080)

* refactor: improve like/dislike interaction

* button style & merge status

* perf

* fix

* i18n

* feedback ui

* format

* api optimize

* openapi

* read status

---------

Co-authored-by: archer <545436317@qq.com>

* perf: remove empty chat

* perf: delete resource tip

* fix: confirm

* feedback filter

* fix: ts

* perf: linker scroll

* perf: feedback ui

* fix: plugin file input store

* fix: max tokens

* update comment

* fix: condition value type

* fix feedback (#6095)

* fix feedback

* text

* list

* fix: versionid

---------

Co-authored-by: archer <545436317@qq.com>

* fix: chat setting render;export logs filter

* add test

* perf: log list api

* perf: redirect check

* perf: log list

* create ui

* create ui

---------

Co-authored-by: heheer <heheer@sealos.io>
This commit is contained in:
Archer
2025-12-15 23:36:54 +08:00
committed by GitHub
parent 13681c9246
commit af669a1cfc
135 changed files with 6363 additions and 2021 deletions
+26 -10
View File
@@ -49,17 +49,34 @@ const addCommonMiddleware = (schema: mongoose.Schema) => {
schema.post(op, function (this: any, result: any, next) {
if (this._startTime) {
const duration = Date.now() - this._startTime;
const warnLogData = {
collectionName: this.collection?.name,
op: this.op,
...(this._query && { query: this._query }),
...(this._update && { update: this._update }),
...(this._delete && { delete: this._delete }),
duration
const getLogData = () => {
const collectionName = this.model?.collection?.name || this._model?.collection?.name;
const op = (() => {
if (this.op) return this.op;
if (this._pipeline) {
return 'aggregate';
}
if (this.constructor?.name === 'model') {
return 'save/create';
}
return this.constructor?.name || 'unknown';
})();
return {
duration,
collectionName,
op,
...(this._query && { query: this._query }),
...(this._pipeline && { pipeline: this._pipeline }),
...(this._update && { update: this._update }),
...(this._delete && { delete: this._delete })
};
};
if (duration > 1000) {
addLog.warn(`Slow operation ${duration}ms`, warnLogData);
if (duration > 2000) {
addLog.warn(`[Mongo Slow] Level2`, getLogData());
} else if (duration > 500) {
addLog.warn(`[Mongo Slow] Level1`, getLogData());
}
}
next();
@@ -112,7 +129,6 @@ export const getMongoModel = <T>(name: string, schema: mongoose.Schema) => {
export const getMongoLogModel = <T>(name: string, schema: mongoose.Schema) => {
if (connectionLogMongo.models[name]) return connectionLogMongo.models[name] as Model<T>;
console.log('Load model======', name);
// addCommonMiddleware(schema);
const model = connectionLogMongo.model<T>(name, schema);
+3 -1
View File
@@ -2,7 +2,9 @@ import { ReadPreference } from './index';
export const readFromSecondary = {
readPreference: ReadPreference.SECONDARY_PREFERRED, // primary | primaryPreferred | secondary | secondaryPreferred | nearest
readConcern: 'local' as any // local | majority | linearizable | available
readConcern: {
level: 'local' as any
} // local | majority | linearizable | available
};
export const writePrimary = {