From 8f2bbd63716be8b831002cf666426135dd0ce888 Mon Sep 17 00:00:00 2001 From: kennsippell Date: Fri, 6 Dec 2024 02:16:30 -0800 Subject: [PATCH] Why 5? wtf --- src/lib/hierarchy-operations/index.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lib/hierarchy-operations/index.js b/src/lib/hierarchy-operations/index.js index 6d0704ba..9834f172 100644 --- a/src/lib/hierarchy-operations/index.js +++ b/src/lib/hierarchy-operations/index.js @@ -47,7 +47,7 @@ function moveHierarchy(db, options) { minifyLineageAndWriteToDisk(options, [...updatedDescendants, ...updatedAncestors]); - const movedReportsCount = await moveReports(db, options, moveContext, destinationId); + const movedReportsCount = await moveReports(db, options, moveContext); trace(`${movedReportsCount} report(s) created by these affected contact(s) will be updated`); affectedContactCount += updatedDescendants.length + updatedAncestors.length; @@ -166,16 +166,18 @@ function replaceLineageInContacts(options, moveContext) { } } - const result = []; - for (const doc of moveContext.descendantsAndSelf) { + function sonarQubeComplexityFiveIsTooLow(doc) { const docIsSource = doc._id === sourceId; // skip top-level because it will be deleted - if (options.merge && docIsSource) { - continue; + if (!options.merge || !docIsSource) { + return replaceForSingleContact(doc); } + } - const updatedDoc = replaceForSingleContact(doc); + const result = []; + for (const doc of moveContext.descendantsAndSelf) { + const updatedDoc = sonarQubeComplexityFiveIsTooLow(doc); if (updatedDoc) { result.push(updatedDoc); }