From 47bf0b9c42c33e6254fc6f8e19af7d51dd6a8488 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 9 Dec 2022 19:40:58 +0530 Subject: [PATCH] feat(gui): add env to disable or enable audit Signed-off-by: Pranav C --- packages/nocodb/src/lib/models/Audit.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/nocodb/src/lib/models/Audit.ts b/packages/nocodb/src/lib/models/Audit.ts index ae2c9f2f6a..2bc902a6fe 100644 --- a/packages/nocodb/src/lib/models/Audit.ts +++ b/packages/nocodb/src/lib/models/Audit.ts @@ -44,6 +44,19 @@ export default class Audit implements AuditType { forceAwait: process.env['TEST'] === 'true', } ) { + // skip audit based on environment variables + if (process.env['NC_AUDIT_META_ENABLE'] === 'false') { + return; + } + + // skip data audit if it is not enabled + if ( + process.env['NC_AUDIT_DATA_ENABLE'] === 'true' && + audit.op_type === AuditOperationTypes.DATA + ) { + return; + } + const insertAudit = async () => { if (!audit.project_id && audit.fk_model_id) { audit.project_id = ( @@ -90,6 +103,7 @@ export default class Audit implements AuditType { return audits?.map((a) => new Audit(a)); } + public static async commentsList(args) { const query = Noco.ncMeta .knex(MetaTable.AUDIT) @@ -115,6 +129,7 @@ export default class Audit implements AuditType { offset, }); } + static async projectAuditCount(projectId: string): Promise { return ( await Noco.ncMeta