feat: refs #7287 Final commit
gitea/mylogger/pipeline/pr-master This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-08-27 09:39:11 +02:00
parent c0a23a0df8
commit fda5726f55
3 changed files with 14 additions and 9 deletions

View File

@ -3,6 +3,7 @@ logRelation: true
logMainShowField: false logMainShowField: false
upperCaseTable: true upperCaseTable: true
userField: editorFk userField: editorFk
reasonField: motivation
rowExcludeField: logExclude rowExcludeField: logExclude
excludeRegex: '__$' excludeRegex: '__$'
showFields: showFields:

View File

@ -94,7 +94,8 @@ module.exports = class ModelLoader {
]; ];
const globalProps = [ const globalProps = [
'userField', 'userField',
'rowExcludeField' 'rowExcludeField',
'reasonField'
]; ];
for (const [schema, table, tableInfo] of schemaMap) { for (const [schema, table, tableInfo] of schemaMap) {
@ -121,8 +122,7 @@ module.exports = class ModelLoader {
tableInfo.castTypes.set(col, tableConf.types[col]); tableInfo.castTypes.set(col, tableConf.types[col]);
const [dbCols] = await db.query( const [dbCols] = await db.query(
`SELECT `SELECT COLUMN_NAME \`col\`,
COLUMN_NAME \`col\`,
DATA_TYPE \`type\` DATA_TYPE \`type\`
FROM information_schema.\`COLUMNS\` FROM information_schema.\`COLUMNS\`
WHERE TABLE_NAME = ? AND TABLE_SCHEMA = ?`, WHERE TABLE_NAME = ? AND TABLE_SCHEMA = ?`,
@ -131,6 +131,7 @@ module.exports = class ModelLoader {
const exclude = new Set(tableConf.exclude); const exclude = new Set(tableConf.exclude);
exclude.add(tableInfo.userField); exclude.add(tableInfo.userField);
exclude.add(tableInfo.reasonField);
for (const {col, type} of dbCols) { for (const {col, type} of dbCols) {
const isExcluded = const isExcluded =

View File

@ -98,7 +98,8 @@ module.exports = class MyLogger {
creationDate = ?, creationDate = ?,
oldInstance = ?, oldInstance = ?,
changedModelValue = ?, changedModelValue = ?,
summaryId = ? summaryId = ?,
reason = ?
WHERE id = ?` WHERE id = ?`
); );
} }
@ -543,6 +544,7 @@ module.exports = class MyLogger {
oldInstance, oldInstance,
modelValue, modelValue,
summaryId, summaryId,
row[tableInfo.reasonField] ?? null,
deleteRow.id deleteRow.id
]); ]);
} }
@ -559,7 +561,8 @@ module.exports = class MyLogger {
newI ? JSON.stringify(newI) : null, newI ? JSON.stringify(newI) : null,
modelId, modelId,
modelValue, modelValue,
summaryId summaryId,
row[tableInfo.reasonField] ?? null
]); ]);
} }