Loggable fixes
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2021-03-24 13:09:35 +01:00
parent c65fbef3df
commit e767e95729
3 changed files with 9 additions and 9 deletions

View File

@ -25,8 +25,8 @@ module.exports = function(Self) {
if (ctx.data) {
const changes = pick(ctx.currentInstance, Object.keys(ctx.data));
newInstance = await fkToValue(ctx.data, ctx);
oldInstance = await fkToValue(changes, ctx);
newInstance = ctx.data;
oldInstance = changes;
if (ctx.where && !ctx.currentInstance) {
const fields = Object.keys(ctx.data);
@ -41,7 +41,7 @@ module.exports = function(Self) {
// Get changes from created instance
if (ctx.isNewInstance)
newInstance = await fkToValue(ctx.instance.__data, ctx);
newInstance = ctx.instance.__data;
ctx.hookState.oldInstance = oldInstance;
ctx.hookState.newInstance = newInstance;
@ -261,6 +261,9 @@ module.exports = function(Self) {
removeUnloggable(definition, oldInstance);
removeUnloggable(definition, newInstance);
oldInstance = await fkToValue(oldInstance, ctx);
newInstance = await fkToValue(newInstance, ctx);
// Prevent log with no new changes
const hasNewChanges = Object.keys(newInstance).length;
if (!hasNewChanges) return;

View File

@ -93,5 +93,7 @@
"New ticket request has been created": "New ticket request has been created *'{{description}}'* for day *{{shipped}}*, with a quantity of *{{quantity}}*",
"There's a new urgent ticket": "There's a new urgent ticket: [{{title}}](https://cau.verdnatura.es/WorkOrder.do?woMode=viewWO&woID={{issueId}})",
"Swift / BIC cannot be empty": "Swift / BIC cannot be empty",
"Role name must be written in camelCase": "Role name must be written in camelCase"
"Role name must be written in camelCase": "Role name must be written in camelCase",
"None": "None",
"Client assignment has changed": "Client assignment has changed"
}

View File

@ -226,11 +226,6 @@ module.exports = Self => {
};
await Self.app.models.ClientCredit.create(newCredit);
}
if (orgData)
ctx.hookState.oldInstance = Object.assign({}, orgData.__data);
if (finalState)
ctx.hookState.newInstance = Object.assign({}, finalState);
});
Self.observe('after save', async ctx => {