Skip to content
This repository was archived by the owner on Jun 9, 2020. It is now read-only.

Commit 09c7b28

Browse files
committed
Merge pull request #14 from crossfilter/fix-filtering-test-array-reduce
Filtering tests and initial 0 for reduce
2 parents 22ee845 + 3b29036 commit 09c7b28

File tree

5 files changed

+29
-7
lines changed

5 files changed

+29
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "universe",
3-
"version": "0.6.0",
3+
"version": "0.6.1",
44
"description": "The fastest way to query and explore multivariate datasets",
55
"main": "src/universe.js",
66
"directories": {

src/aggregation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,13 @@ function convertAggregatorString(keyString) {
189189
function $sum(children) {
190190
return children.reduce(function(a, b) {
191191
return a + b
192-
})
192+
}, 0)
193193
}
194194

195195
function $avg(children) {
196196
return children.reduce(function(a, b) {
197197
return a + b
198-
}) / children.length
198+
}, 0) / children.length
199199
}
200200

201201
function $max(children) {

test/postAggregation.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,28 @@ describe('universe postAggregation', function() {
8282
})
8383
})
8484

85+
it('works after filtering', function() {
86+
var query
87+
return u.then(function(u) {
88+
return u.query({
89+
groupBy: 'total',
90+
})
91+
})
92+
.then(function(res) {
93+
return res.changeMap({
94+
count: true
95+
})
96+
})
97+
.then(function(res) {
98+
query = res
99+
expect(res.data[0].value.countChangeFromEnd).to.equal(5)
100+
return res.universe.filter('type', 'cash')
101+
})
102+
.then(function(){
103+
expect(query.data[0].value.countChangeFromEnd).to.equal(0)
104+
})
105+
})
106+
85107
it('can sortByKey ascending and descending', function() {
86108
return u.then(function(u) {
87109
return u.query({

universe.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

universe.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)