refs #5541 Debug fixes, fetch delete id index usage fix
gitea/mylogger/pipeline/head This commit looks good Details

This commit is contained in:
Juan Ferrer 2023-05-13 14:25:50 +02:00
parent 810fb55416
commit 16391f146d
3 changed files with 9 additions and 7 deletions

View File

@ -167,7 +167,9 @@ module.exports = class MyLogger {
`SELECT id FROM ${sqlTable} `SELECT id FROM ${sqlTable}
WHERE changedModel = ? WHERE changedModel = ?
AND changedModelId = ? AND changedModelId = ?
AND action = 'delete'` AND action = 'delete'
AND (originFk IS NULL OR originFk = ?)
LIMIT 1`
); );
logInfo.updateStmt = await db.prepare( logInfo.updateStmt = await db.prepare(
`UPDATE ${sqlTable} `UPDATE ${sqlTable}
@ -542,7 +544,7 @@ module.exports = class MyLogger {
if (!changes.length) return; if (!changes.length) return;
if (this.debug) if (this.conf.debug)
console.debug('Evt:'.blue, console.debug('Evt:'.blue,
`[${action}]`[actionColor[action]], `${tableName}: ${changes.length} changes`); `[${action}]`[actionColor[action]], `${tableName}: ${changes.length} changes`);
@ -644,14 +646,14 @@ module.exports = class MyLogger {
: modelId; : modelId;
let deleteRow; let deleteRow;
if (this.debug) if (this.conf.debug)
console.debug('Log:'.blue, console.debug('Log:'.blue,
`[${action}]`[actionColor[action]], `${modelName}: ${modelId}`); `[${action}]`[actionColor[action]], `${modelName}: ${modelId}`);
try { try {
if (isDelete) { if (isDelete) {
[[deleteRow]] = await logInfo.fetchStmt.execute([ [[deleteRow]] = await logInfo.fetchStmt.execute([
modelName, modelId modelName, modelId, originFk
]); ]);
if (deleteRow) if (deleteRow)
await logInfo.updateStmt.execute([ await logInfo.updateStmt.execute([

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "mylogger", "name": "mylogger",
"version": "0.1.14", "version": "0.1.15",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "mylogger", "name": "mylogger",
"version": "0.1.14", "version": "0.1.15",
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"colors": "^1.4.0", "colors": "^1.4.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "mylogger", "name": "mylogger",
"version": "0.1.14", "version": "0.1.15",
"author": "Verdnatura Levante SL", "author": "Verdnatura Levante SL",
"description": "MySQL and MariaDB logger using binary log", "description": "MySQL and MariaDB logger using binary log",
"license": "GPL-3.0", "license": "GPL-3.0",