Skip to content

Commit

Permalink
Housekeeping on cached RollupRelationshipFieldFinder.traversal while …
Browse files Browse the repository at this point in the history
…investigating #616
  • Loading branch information
jamessimone committed Aug 22, 2024
1 parent ceb746d commit 37ebef7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
23 changes: 20 additions & 3 deletions extra-tests/classes/RollupFullRecalcTests.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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<SObject>{ parentB, parentC };
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions rollup/core/classes/RollupAsyncProcessor.cls
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ global virtual without sharing class RollupAsyncProcessor extends Rollup impleme
List<SObject> 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
Expand Down

0 comments on commit 37ebef7

Please sign in to comment.