Skip to content

Commit

Permalink
Added support for Count Distinct
Browse files Browse the repository at this point in the history
See
#9
9
  • Loading branch information
afawcettffdc committed Feb 11, 2015
1 parent df849ad commit e9a322e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rolluptool/src/classes/LREngine.cls
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public class LREngine {
Which rollup operation you want to perform
*/
public enum RollupOperation {
Sum, Max, Min, Avg, Count
Sum, Max, Min, Avg, Count, Count_Distinct
}

/**
Expand Down
9 changes: 7 additions & 2 deletions rolluptool/src/classes/RollupServiceTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ private with sharing class RollupServiceTest
{
testSingleRollup(new List<Decimal> { 250, 250, 50, 50 }, 4, RollupSummaries.AggregateOperation.Count, null);
}


private testmethod static void testSingleCountDistinctRollup()
{
testSingleRollup(new List<Decimal> { 250, 250, 50, 50 }, 2, RollupSummaries.AggregateOperation.Count_Distinct, null);
}

private testmethod static void testSingleSumRollupConditional()
{
testSingleRollup(new List<Decimal> { 250, 250, 50, 50 }, 500, RollupSummaries.AggregateOperation.Sum, 'Amount > 200');
Expand Down Expand Up @@ -922,7 +927,7 @@ private with sharing class RollupServiceTest
rollupSummary.RelationShipField__c = 'AccountId';
rollupSummary.RelationShipCriteria__c = condition; // 'Amount > 200';
rollupSummary.FieldToAggregate__c = 'Amount';
rollupSummary.AggregateOperation__c = operation.name();
rollupSummary.AggregateOperation__c = operation.name().replace('_', ' ');
rollupSummary.AggregateResultField__c = 'AnnualRevenue';
rollupSummary.Active__c = true;
rollupSummary.CalculationMode__c = 'Realtime';
Expand Down
6 changes: 4 additions & 2 deletions rolluptool/src/classes/RollupSummaries.cls
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public with sharing class RollupSummaries extends SObjectDomain
AggregateOperation.Max.name() => LREngine.RollupOperation.Max,
AggregateOperation.Min.name() => LREngine.RollupOperation.Min,
AggregateOperation.Avg.name() => LREngine.RollupOperation.Avg,
AggregateOperation.Count.name() => LREngine.RollupOperation.Count
AggregateOperation.Count.name() => LREngine.RollupOperation.Count,
AggregateOperation.Count_Distinct.name().replace('_', ' ') => LREngine.RollupOperation.Count_Distinct
};

/**
Expand All @@ -64,7 +65,8 @@ public with sharing class RollupSummaries extends SObjectDomain
Max,
Min,
Avg,
Count
Count,
Count_Distinct
}

public RollupSummaries(List<LookupRollupSummary__c> records)
Expand Down
4 changes: 4 additions & 0 deletions rolluptool/src/objects/LookupRollupSummary__c.object
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
<fullName>Count</fullName>
<default>false</default>
</picklistValues>
<picklistValues>
<fullName>Count Distinct</fullName>
<default>false</default>
</picklistValues>
<sorted>false</sorted>
</picklist>
<type>Picklist</type>
Expand Down

0 comments on commit e9a322e

Please sign in to comment.