Skip to content

Commit 1ebf0db

Browse files
committed
Go back to only allowing a single count aggregation per group 'level'
1 parent faa3c9a commit 1ebf0db

File tree

5 files changed

+18
-21
lines changed

5 files changed

+18
-21
lines changed

reductio.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ function accessor_build(obj, p) {
154154
obj.count = function(value, propName) {
155155
if (!arguments.length) return p.count;
156156
if (!propName) {
157-
propName = p.count.length === 0 ? 'count' : ('count' + (p.count.length+1));
157+
propName = 'count';
158158
}
159-
p.count.push([value, propName]);
159+
p.count = propName;
160160
return obj;
161161
};
162162

@@ -179,7 +179,7 @@ function accessor_build(obj, p) {
179179
if(p.sum) console.warn('SUM aggregation is being overwritten by AVG aggregation');
180180
p.sum = value;
181181
p.avg = true;
182-
if(p.count.length === 0) p.count.push([true,'count']);
182+
p.count = 'count';
183183
} else {
184184
p.avg = value;
185185
}
@@ -296,7 +296,7 @@ function accessor_build(obj, p) {
296296
if(typeof(value) === 'function') {
297297
p.sumOfSquares = value;
298298
p.sum = value;
299-
if(p.count.length === 0) p.count.push([true, 'count']);
299+
p.count = 'count';
300300
p.std = true;
301301
} else {
302302
p.std = value;
@@ -469,11 +469,9 @@ function build_function(p, f, path) {
469469
};
470470

471471
if(p.count || p.std) {
472-
p.count.forEach(function(c) {
473-
f.reduceAdd = reductio_count.add(f.reduceAdd, path, c[1]);
474-
f.reduceRemove = reductio_count.remove(f.reduceRemove, path, c[1]);
475-
f.reduceInitial = reductio_count.initial(f.reduceInitial, path, c[1]);
476-
});
472+
f.reduceAdd = reductio_count.add(f.reduceAdd, path, p.count);
473+
f.reduceRemove = reductio_count.remove(f.reduceRemove, path, p.count);
474+
f.reduceInitial = reductio_count.initial(f.reduceInitial, path, p.count);
477475
}
478476

479477
if(p.sum) {

0 commit comments

Comments
 (0)