Skip to content

Commit

Permalink
Fixes an issue reported by Katherine West where rollup ordering wasn'…
Browse files Browse the repository at this point in the history
…t being properly applied
  • Loading branch information
jamessimone committed Sep 30, 2024
1 parent 877a3b6 commit fb94e97
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" ?>
<CustomMetadata
xmlns="http://soap.sforce.com/2006/04/metadata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<label>Integration NumberValue FIRST</label>
<protected>false</protected>
<values>
<field>FieldName__c</field>
<value xsi:type="xsd:string">NumberField__c</value>
</values>
<values>
<field>NullSortOrder__c</field>
<value xsi:type="xsd:string">NULLS FIRST</value>
</values>
<values>
<field>Ranking__c</field>
<value xsi:type="xsd:double">1.0</value>
</values>
<values>
<field>Rollup__c</field>
<value xsi:type="xsd:string">RollupIntegrationChildRollupText</value>
</values>
<values>
<field>SortOrder__c</field>
<value xsi:type="xsd:string">Ascending</value>
</values>
</CustomMetadata>
3 changes: 2 additions & 1 deletion rollup/core/classes/RollupCalculator.cls
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,9 @@ public without sharing abstract class RollupCalculator {
protected List<WinnowResult> winnowItems(List<SObject> items, Map<Id, SObject> oldCalcItems) {
List<RollupOrderBy__mdt> orderBys = this.metadata?.LimitAmount__c != null && this.metadata.RollupOrderBys__r.isEmpty()
? new List<RollupOrderBy__mdt>{ new RollupOrderBy__mdt(FieldName__c = 'Id', Ranking__c = 0) }
: this.metadata.RollupOrderBys__r;
: new List<RollupOrderBy__mdt>(this.metadata.RollupOrderBys__r);
if (orderBys.isEmpty() == false) {
orderBys.sort(new RollupRepository.OrderBySorter());
items.sort(new RollupCalcItemSorter(orderBys));
}
List<WinnowResult> winnowedItems = new List<WinnowResult>();
Expand Down
3 changes: 1 addition & 2 deletions rollup/core/classes/RollupRepository.cls
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public without sharing class RollupRepository implements RollupLogger.ToStringOb
SharingMode__c,
ShouldRunWithoutCustomSettingEnabled__c,
SplitConcatDelimiterOnCalcItem__c,
(SELECT Id, FieldName__c, NullSortOrder__c, Ranking__c, SortOrder__c FROM RollupOrderBys__r),
(SELECT Id, DeveloperName, FieldName__c, NullSortOrder__c, Ranking__c, SortOrder__c FROM RollupOrderBys__r),
RollupGrouping__r.Id,
RollupGrouping__r.RollupOperation__c
FROM Rollup__mdt
Expand All @@ -149,7 +149,6 @@ public without sharing class RollupRepository implements RollupLogger.ToStringOb
meta.GroupByRowStartDelimiter__c = meta.GroupByRowStartDelimiter__c?.unescapeJava();
meta.SharingMode__c = meta.SharingMode__c ?? RollupMetaPicklists.SharingMode.SystemLevel;
meta.UltimateParentLookup__c = meta.UltimateParentLookup__r.QualifiedApiName;
meta.RollupOrderBys__r.sort(new OrderBySorter());
}

return matchingMetadata;
Expand Down
9 changes: 3 additions & 6 deletions sfdx-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"package": "apex-rollup",
"path": "rollup",
"scopeProfiles": true,
"versionName": "Fixes parentRecordIdForEmptyChildrenCollections flow case",
"versionNumber": "1.6.34.0",
"versionName": "Fixes Rollup Order By sorting to always be deterministic",
"versionNumber": "1.6.35.0",
"versionDescription": "Fast, configurable, elastically scaling custom rollup solution. Apex Invocable action, one-liner Apex trigger/CMDT-driven logic, and scheduled Apex-ready.",
"releaseNotesUrl": "https://github.com/jamessimone/apex-rollup/releases/latest",
"unpackagedMetadata": {
Expand Down Expand Up @@ -101,12 +101,9 @@
"Apex Rollup - Rollup [email protected]": "04t6g000008Sis0AAC",
"Nebula Logger - [email protected]": "04t5Y0000015oRNQAY",
"apex-rollup": "0Ho6g000000TNcOCAW",
"[email protected]": "04t6g000008ObN8AAK",
"[email protected]": "04t6g000008ObNNAA0",
"[email protected]": "04t6g000008ObVhAAK",
"[email protected]": "04t6g000008ObblAAC",
"[email protected]": "04t6g000008ObbvAAC",
"[email protected]": "04t6g000008ObeQAAS",
"[email protected]": "04t6g000008OfJfAAK"
}
}
}

0 comments on commit fb94e97

Please sign in to comment.