From 37ebef7f1f6314fd2a7497c9743750b06ac5a332 Mon Sep 17 00:00:00 2001 From: James Simone <16430727+jamessimone@users.noreply.github.com> Date: Thu, 22 Aug 2024 10:40:08 -0400 Subject: [PATCH] Housekeeping on cached RollupRelationshipFieldFinder.traversal while investigating #616 --- extra-tests/classes/RollupFullRecalcTests.cls | 23 ++++++++++++++++--- rollup/core/classes/RollupAsyncProcessor.cls | 1 + 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/extra-tests/classes/RollupFullRecalcTests.cls b/extra-tests/classes/RollupFullRecalcTests.cls index ae76acb7..e2a5e655 100644 --- a/extra-tests/classes/RollupFullRecalcTests.cls +++ b/extra-tests/classes/RollupFullRecalcTests.cls @@ -1738,8 +1738,8 @@ private class RollupFullRecalcTests { @IsTest static void limitsFullBatchRecalcCachedItemsProperly() { - Rollup.defaultControl = new RollupControl__mdt(ShouldRunAs__c = RollupMetaPicklists.ShouldRunAs.Synchronous); - Account parentA = [SELECT Id FROM Account]; + Rollup.defaultControl = new RollupControl__mdt(ShouldRunAs__c = RollupMetaPicklists.ShouldRunAs.Synchronous, IsRollupLoggingEnabled__c = true); + Account parentA = [SELECT Id, OwnerId FROM Account]; Account parentB = new Account(Name = 'Parent B'); Account parentC = new Account(Name = 'Parent C'); insert new List{ parentB, parentC }; @@ -1768,7 +1768,22 @@ private class RollupFullRecalcTests { LookupObject__c = 'Account', LookupFieldOnLookupObject__c = 'Id', RollupFieldOnLookupObject__c = 'AnnualRevenue', - RollupOperation__c = 'SUM' + RollupOperation__c = 'SUM', + FullRecalculationDefaultNumberValue__c = 0, + IsFullRecordSet__c = true + ), + new Rollup__mdt( + CalcItem__c = 'ContactPointAddress', + RollupFieldOnCalcItem__c = 'PreferenceRank', + LookupFieldOnCalcItem__c = 'ParentId', + LookupObject__c = 'User', + LookupFieldOnLookupObject__c = 'Id', + RollupFieldOnLookupObject__c = 'JigsawImportLimitOverride', + GrandparentRelationshipFieldPath__c = 'Parent.Owner.JigsawImportLimitOverride', + RollupOperation__c = 'SUM', + CalcItemWhereClause__c = 'ParentId = \'' + parentA.Id + '\'', + FullRecalculationDefaultNumberValue__c = 0, + IsFullRecordSet__c = true ), new Rollup__mdt( CalcItem__c = 'ContactPointAddress', @@ -1817,6 +1832,8 @@ private class RollupFullRecalcTests { System.assertEquals(String.valueOf(true), parent.Sic, parent); } System.assertEquals(true, Rollup.CACHED_ROLLUPS.isEmpty(), 'all deferrals should have been run'); + User parentAOwner = [SELECT Id, JigsawImportLimitOverride FROM User WHERE Id = :parentA.OwnerId]; + System.assertEquals(6, parentAOwner.JigsawImportLimitOverride); } @IsTest diff --git a/rollup/core/classes/RollupAsyncProcessor.cls b/rollup/core/classes/RollupAsyncProcessor.cls index 855cfaad..04a0309c 100644 --- a/rollup/core/classes/RollupAsyncProcessor.cls +++ b/rollup/core/classes/RollupAsyncProcessor.cls @@ -728,6 +728,7 @@ global virtual without sharing class RollupAsyncProcessor extends Rollup impleme List localLookupItems = this.getLookupItems(calcItemsByLookupField, updatedLookupRecords, roll); this.logger.log('starting rollup for:', roll, System.LoggingLevel.INFO); updatedLookupRecords.putAll(this.getUpdatedLookupItemsByRollup(roll, calcItemsByLookupField, localLookupItems)); + roll.traversal = null; } // full batch recalc housekeeping - allow next batch chunk to reference previously reset parents