Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion slick.dataview.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
Avg: AvgAggregator,
Min: MinAggregator,
Max: MaxAggregator,
Sum: SumAggregator
Sum: SumAggregator,
Count: CountAggregator
}
}
}
Expand Down Expand Up @@ -1120,6 +1121,28 @@
}
}

function CountAggregator(field) {
this.field_ = field;

this.init = function () {
this.sum_ = 0;
};

this.accumulate = function (item) {
var val = item[this.field_];
if (val != null && val !== "") {
this.sum_ += 1
}
};

this.storeResult = function (groupTotals) {
if (!groupTotals.sum) {
groupTotals.sum = {};
}
groupTotals.sum[this.field_] = this.sum_;
}
}

// TODO: add more built-in aggregators
// TODO: merge common aggregators in one to prevent needles iterating

Expand Down